fczuardi / instagram-hashtag

Shell scripts to get metadata from instagram photos of a certain hashtag without the API, hacking browser calls instead. ( visaourbanaiz )
Other
7 stars 0 forks source link

Instagram Bulk Photo Downloader by Tag

(hackish without using the API)

This repo contains a series of shell scripts that helps bulk downloading instagram photos with a particular tag.

It can be useful for:

Disclaimer

Backup, export or download Instagram photos might have copyright implications.

Also, using any of the shell scripts provided here might be a violation of Instagram's Terms of Use, I don't know and I don't care.

Please read Instaram's restrictions carefully, read the source code carefully and understand all the risks and consequences before trying it.

Always use their official API whenever possible. This hack is a hack with no guarantees whatsoever that it will work today or that it will continue to work in the future.

Use it for study, for personal uses, and at your own risk.

Requirements

Usage

1. Open the instagram page of the tag you want to download photos from:

Example: https://www.instagram.com/explore/tags/cuteDogs/

2. Open your browser's developer tools:

screen shot 2016-05-22 at 10 54 57 am

3. Select the "Network" tab and refresh the page. Then look for the first query/ request line:

screen shot 2016-05-22 at 11 00 50 am

4. Click on that line and on the Headers tab you will find the content that you will have to fill-in on the hack.sh script

screen shot 2016-05-22 at 11 10 21 am

Of the screenshot above, the boxes correspond to the following variables on hack.sh:

COOKIEHEADER="Contents of the Yellow area here"
XCSRFTOKENHEADER="Contents of the Pink area here"
STARTCURSOR="Contents of the Blue area here"

5. Replace the value of the variable HASHTAG with the tag you want to backup photos from.

6. Get the metadata

On your terminal type:

./hack.sh

A folder named json will be created and the metadata of all pages will be stored there.

7. Generate the url lists

On your terminal type:

./photourls.sh

This will generate 2 files, urls.txt that is the list of all urls, and curl-urls.txt that is a curl config file for downloading all images.

8. Download!

Copy the curl-urls.txt file you've generated in the previous step to the folder you want to download all pictures and run:

curl -K curl-urls.txt

Other scripts

This repo also contain a script for generating a .csv file based on the metadata of the json folder: metadata.sh and a script to rename downloaded files to include author username, date and Instagram's shortcode of a photo in the filename (rename-photos.sh), based on the csv file generated by the metadata script.

License AGPL v3.0

Copyright (c) 2016 Fabricio C Zuardi

This software is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE version 3.