Instagram location data gathering tool. Usage: python3 instaloctrack.py -t <target_account>
optional arguments: -h, --help show this help message and exit -t TARGET_ACCOUNT, --target TARGET_ACCOUNT Instagram profile to investigate -l LOGIN, --login LOGIN Instagram profile to connect to, in order to access the instagram posts of the target account -p PASSWORD, --password PASSWORD Password of the Instagram profile to connect to -v, --visual Spawns Chromium GUI, otherwise Chromium is headless
instaloctrack -t <target_account>
If the target profile is private and you have an account following the target profile you can scrape the data with a connected session:
sudo docker run -v /tmp/output:/tmp/output instaloctrack -t <target_account> -o /tmp/output
How it works
First, we retrieve all the pictures links of the account by scrolling the whole Instagram profile, thanks to selenium’s webdriver.
Then, we retrieve asynchronously (asyncio) each picture link, we check if it contains a location in the picture description, and retrieve the location’s data if there’s one, and the timestamp.
NB: Since 2018 Instagram deprecated its location API and it’s not possible anymore to get the GPS coordinates of a picture, all we can retrieve is the name of the location. (If you can prove me that I’m wrong about this, please tell me!)
Because Instagram doesn’t provide GPS coordinates, and we’re only given names of places, we have to geocode these (.ie. get the GPS coords from the name’s place).
For this, I used Nominatim’s awesome API, which uses OpenStreetMap. For our usage, no API key is required, and we respect Nominatim’s usage Policy by requesting GPS coordinatess once every second.
Also, the data collected by the script (location names, timestamps, GPS coordinates, errors) are dumped to a JSON file in order to be re-used.
As an example, here’s the output on the former French President’s Instagram profile, @fhollande:
Information available when clicking on a marker:
Stats about the location data:
The JSON data dump (just a part of it to show the format for a given location):