Build an interactive network of your Instagram followers and their relations in 3 easy steps! (and quite some time)
Note
Proof of concept. Use at your own responsibility, as it may violate Instagram's TOS.
I do not take responsibility for any consequences to Instagram accounts after using this project.
Instagram might find it suspicious to use bots. To avoid errors, add 2FA and use Instaloader carefully.
Clone the repo:
git clone https://github.com/victor-gurbani/instagram_network_analysis/
cd instagram_network_analysis
Install the dependencies:
pip install instaloader -U
pip install requirements.txt
And set your Instagram username in the config.json file.
nano config.json
Login to Instagram either using
- Instaloader CLI:
instaloader --login=USERNAME
- Your preferred browser and run:
pip install browser-cookie3 -U && instaloader --load-cookies=BROWSER
where BROWSER is chrome, firefox, safari, etc... To avoid detection, use your browser for a few days.
Start scraping your profile and your followers followers:
cd 01\ scraping/
python3 get_my_followers.py
python3 get_relations.py --wait-time 10
python3 relations_to_json.py
--wait-time can be omitted but set it to a high value in seconds to avoid detection
--max-count to set a limit on how many users to scrape before the script exits (progress is saved and can be resumed directly)
To monitor the scraping you can tail -F relations.txt
Caution
Errors usually occur after Instagram blocks the session due to suspecting that you are using bots.
You'll need to log in again to restore the Instaloader session.
Finished! Now visualise it and process the data!
Go to the corresponding folder 02 visual
and copy the relations.json file:
cd 02\ visual/ && cp ../01\ scraping/relations.json relations.json
and start or open index.html
in your preferred browser (with JS enabled).
Analyse the data
First, go to the third folder copying the data:
cd 03\ analysis/ && cp ../01\ scraping/relations.* ./
And run the analysis scripts! (idk if the community detection works but the other two work fine)
Original step-by-step guide on how to use the code and interpret the results: https://medium.com/@maximpiessen/how-i-visualised-my-instagram-network-and-what-i-learned-from-it-d7cc125ef297