Instagram Scraping

Note the rate limit on 20 most recent items


In [ ]:
import json
import shutil
import requests

In [ ]:
with open('data.json') as data_file:    
    data = json.load(data_file)

In [ ]:
image_count = 0
def download_image(url):
    response = requests.get(url, stream=True)
    with open('img_' + str(image_count) +  '.jpg', 'wb') as out_file:
        shutil.copyfileobj(response.raw, out_file)
    del response
    global image_count
    image_count+=1

In [ ]:
for i in data['items']:
    download_image(i['images']['standard_resolution']['url'])