Last active
May 19, 2019 16:57
-
-
Save rvvvt/e75d1aa3bc7b40e4bb1ce8ae2a05d4ba to your computer and use it in GitHub Desktop.
Dirty lil instagram image scraper - downloads images by tag name. Aw yis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import requests | |
tag = 'mpower' | |
r = requests.get('http://www.instagram.com/explore/tags/' + tag + '/') | |
html = r.text | |
# print(html) | |
img = re.compile('(?:\"display_url\":\")([^\"]+)\"') | |
images = img.findall(html) | |
count = 0 | |
for line in images: | |
Picture_request = requests.get(line) | |
if Picture_request.status_code == 200: | |
filename = tag + str(count) | |
print('rippin ' + line) | |
with open('c:\\image_test\\' + tag + '\\' + filename + '.jpg', 'wb') as f: | |
f.write(Picture_request.content) | |
count = count + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment