This is (hopefully) a beginner friendly guide to scrape instagram accounts using the Digital Methods Initiative instagram batch scrape tool.
More infos here: https://github.com/digitalmethodsinitiative/instagram-batch-scrape
For the most steps you will need to use the command line interface, use the terminal app if you are on Mac or Linux, use the Command Prompt if on Windows.
If you haven’t yet installed python 3, you need to do this first. Follow the tutorial for either Linux, Mac or Windows:
https://realpython.com/installing-python/
Type the following (in the grey boxes) in your terminal
Clone the git repository (this is a fork of the offical repository, so we can mess with the code)
git clone https://github.com/digitalmethodsinitiative/instagram-batch-scrape.git
(Note: if you want to switch to a different folder, use the cd command)
cd instagram-batch-scrape
pip3 install -r requirements.txt
You can do this either from the command line or just edit the files directly using e.g. finder, the graphical user interface.
config.py-example
and rename it to config.py
batch.txt
Copy config example file to config.py
cp config.py-example config.py
fill in username and password (and number of posts)
sudo nano config.py
create and edit batch.txt: in this file you enter the accounts you want to scrape (one account-name per line)
sudo nano batch.txt
python3 scrape-batch.py --batchfile batch.txt
The result should look something like this.
The script exports the results as two CSV files and a graph file (located in the same folder as the script is in):
If you want to track changes over time, it might be of insterest to schedule the script (run it every 30 minutes)
The following only works on Unix-based systems (Mac & Linux) so not on Windows.
For Windows maybe this helps: https://www.windowscentral.com/how-create-task-using-task-scheduler-command-prompt
create a crontab for your user:
env EDITOR=nano crontab -e
in this file enter:
PATH=/usr/local/bin:/usr/bin:/bin
*/30 * * * * cd ~/projects/instagram-batch-scrape/ && python3 scrape-batch.py --batchfile batch.txt -t TRUE >> ~/projects/instagram-batch-scrape/script_output.log
! replace ~/projects/instagram-batch-scrape/ with the path to your script folder !
*/30 * * * * stands for every 30th minute, so you can change this to 10 if you want it to run every 10th minute.
save using ctrl-c and confirm with y
If on macOS you might get a popup asking for permission. In order for the script to work you have to accept this