Let’s say you want to downloaded the images uploaded to Instagram by you and your contacts, for backup reasons.
You can login at the regular web application at https://instagram.com and right-click/inspect your way to the actual URI of the image file. Manually downloading one photo at a time soon becomes boring though, let’s look for other alternatives.
There are a couple of sites that promote applications that does the job for you. The ones I saw wanted my username and password, which is out of the question.
Let’s try to do download the images ourselves instead, from an environment we control, our desktop.
Installing a scraper on your own computer to download photos
The rest of this blog post assumes that you are using Linux or macOS (for
cron and regular CLI tools), and have python installed (for the scraping program).
The next thing we are going to do is to configure who you are and which profiles you want to download. You do that by creating a text file:
Let’s try it out:
If you’ve got image files in the folder referred to by
--destination, you are home free.
Automating the scraping
To avoid executing the above command manually, we use cron to fetch new images for us.
This is what a my crontab looks like:
To edit your own crontab, use the command
If you need to learn the syntax of cron, there’s a handy form at https://crontab.guru/ that could help you.
Viewing newly downloaded images
I use a minimal image viewer called sxiv which is available in the default repos of, at least, Fedora.
The following command let’s you view all recently downloaded images:
where the first argument to
find is the value of
--destination in your configuration, and
-10 let’s you view images from the last ten days.
Notes about availability of images
All images uploaded to Instagram, even by those with their profiles set to private, are publicly accessible. Getting to know the URI is the only problem, that’s why we use the scraping application, to find the correct URIs. Even though the URIs themselves do not require being authenticated to download, there may be rate limits or other counter measures against downloading images in bulk.
Shortcuts in the code
- Feel free to
pip install --userinstead.
- Feel free to capture the stdout/stderr from the cronjob.