Skip to content

Instantly share code, notes, and snippets.

@rvvvt
Last active May 19, 2019 16:57
Show Gist options
  • Save rvvvt/e75d1aa3bc7b40e4bb1ce8ae2a05d4ba to your computer and use it in GitHub Desktop.
Save rvvvt/e75d1aa3bc7b40e4bb1ce8ae2a05d4ba to your computer and use it in GitHub Desktop.
Dirty lil instagram image scraper - downloads images by tag name. Aw yis.
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