Skip to content

Instantly share code, notes, and snippets.

@oliver-batey
Created December 23, 2020 20:16
Show Gist options
  • Save oliver-batey/f2f5feeb59cf40efc1dc0498d6145830 to your computer and use it in GitHub Desktop.
Save oliver-batey/f2f5feeb59cf40efc1dc0498d6145830 to your computer and use it in GitHub Desktop.
Download instagram images
#Scrape profile and get recent posts
natgeo = Profile('natgeo')
natgeo.scrape()
recents = natgeo.get_recent_posts()
#Filter list to separate images from videos
recent_photos = [post for post in recents if not post.is_video]
#Save photos in a loop
for i, post in enumerate(recent_photos):
savename = 'natgeo_image_{}.png'.format(i)
post.download(savename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment