Skip to content

Instantly share code, notes, and snippets.

@elky elky/scraper.py
Created Jun 15, 2018

Embed
What would you like to do?
instagram-scraper without having to run shell command. May need for security reasons (passing variables to shell command on server is risky)
from instagram_scraper.app import InstagramScraper
def scrape_instagram_feed(form_data):
data = {
'username': form_data.get('username'),
'usernames': [form_data.get('username')],
'login_user': form_data.get('username'),
'login_pass': form_data.get('password'),
'destination': 'instagram_data',
'media_metadata': True,
'media_types': ['none'],
'maximum': 100
}
scraper = InstagramScraper(**data)
scraper.login()
scraper.scrape()
path = 'instagram_data/%s.json' % username
try:
with open(path) as f:
result = []
for item in json.load(f):
if item['__typename'] == 'GraphImage':
result.append(item['display_url'])
return result
except:
print 'An error has occurred. Please check username/password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.