Instaloctrack – Instagram OSINT Tool to Collect All Geotagged Locations on an Instagram User

Instaloctrack - Tool to Track Instagram User Locations

instaloctrack

An Instagram OSINT tool to collect all the geotagged locations available on an Instagram profile in order to plot them on a map, and dump them in a JSON.

A tool to scrape geotagged locations on Instagram profiles. Output in JSON & interactive map.

Demo

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.

Eventually, once we have all the GPS coordinatess, we generate a HTML (thanks to jinja2 templating) with Javascript embedded that plots an Open Street Map (thanks to Leaflet library) with all our locations pinned. Once again, no API key is required for this step.

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.

Requirements

sudo apt install chromium-chromedriver && chmod a+x /usr/bin/chromedriver

Installation

git clone https://github.com/bernsteining/instaloctrack cd instaloctrack pip3 install .

Or use Docker:

sudo docker build -t instaloctrack -f Dockerfile .

Usage

example

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:

instaloctrack -t (target_account) -l (your_account) -p (your_password)

Live Example

As an example, here’s the output on the former French President’s Instagram profile, @fhollande:

Instaloctrack - Instagram OSINT Tool to Collect All Geotagged Locations on an Instagram User

The Heatmap:

Instaloctrack - Instagram OSINT Tool to Collect and Scrape All Geotagged Locations on an Instagram User

Information available when clicking on a marker:

Instaloctrack - Tool to Track Instagram User Locations

Statistics about the location data:

Instaloctrack - Instagram OSINT Tool to Collect and Scrape All Locations on an Instagram User

Possible Improvements

  • Cleaner code 😀
  • Factorize the geocoding function which is waaay too long and cryptic
  • Use beautifulsoup instead of regex parsing
  • Remove weird blank space caused by progress bar
  • Use other geocoding tools (e.g. https://geo.api.gouv.fr/adresse) than Nominatim when it fails? (specify arg?)
    • Use geopy ?
    • Use Overpass instead of Nominatim ?
  • Add an argument to select only a set of pictures (selected by date, or rank)
  • Time information about the duration of the script

You May Also Like

Leave a Reply

Your email address will not be published.

20 − 2 =