Skip to content

Instantly share code, notes, and snippets.

@viktor02
Last active July 13, 2020 19:34
Show Gist options
  • Select an option

  • Save viktor02/bf1d385f322de58d3dc447d5607b4f6a to your computer and use it in GitHub Desktop.

Select an option

Save viktor02/bf1d385f322de58d3dc447d5607b4f6a to your computer and use it in GitHub Desktop.
Backup stories, photos and videos of any accounts on Instagram

Backup stories, photos and videos on instagram

Installation

  1. pip install instagram-scraper
  2. Write the desired accounts to a file targets.txt
  3. Change the username and password in scraper.py
  4. Run scraper.py

Folder structure

E:.
│   instagram-scraper.log
│   scraper.py
│   targets.txt
│
├───images
│   ├───durov
│   └───kevin
├───stories
│   ├───durov
│   └───kevin
├───videos
│   ├───durov
│   └───kevin

Tips

  • You can download multiple profiles at the same time.
  • You can add a script to a dedicated server and run on the cron - you will get autosave of all stories and photos that can be deleted by the author. By the way, when you re-run the script, saving will begin from the photo where you stopped last time.
instagram-scraper>=1.9.0
import subprocess
username = "your_username"
password = "your_password"
download_story = subprocess.run(["instagram-scraper", "-f", "targets.txt", "--media-types", "story", "-n", "-d", "stories", "-u", username, "-p", password, "--latest", "--include-location", "--profile-metadata"])
download_image = subprocess.run(["instagram-scraper", "-f", "targets.txt", "--media-types", "image", "-n", "-d", "images", "-u", username, "-p", password, "--latest", "--include-location", "--profile-metadata"])
download_video = subprocess.run(["instagram-scraper", "-f", "targets.txt", "--media-types", "video", "-n", "-d", "videos", "-u", username, "-p", password, "--latest", "--include-location", "--profile-metadata"])
# The usernames may be separated by newlines, commas, semicolons, or whitespace.
kevin
durov
# etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment