Information Gathering

Instagram Location Search: Navigating and Scraping Proximal Points with Ease

Find out how powerful Instagram Location Search is. It’s a flexible Python tool that makes it easier to find and analyze Instagram places. This app lets you map coordinates in downtown Tucson or anywhere else, and it gives different output formats, from CSV to GeoJSON, so you can do useful geospatial analysis. Instagram position Search is a must-have tool for digital researchers, marketers, and social media analysts because it can make visual maps and position IDs that can be used with instagram-scraper. This guide goes into detail about how to install it, how to use it, and how to handle Instagram cookies, so you have all the tools you need to do advanced Instagram data exploration.

Installation

This Python application can be installed from PyPI using pip: pip install instagram-location-search

or the latest from the repo: pip install git+https://github.com/bellingcat/instagram-location-search

Example usage

The following command will search for Instagram locations nearby the coordinates 32.22 N, 110.97 W (downtown Tucson, Arizona.) The list of locations is saved as a CSV file at “locs.csv”.

instagram-location-search --cookie "<instagram-cookies>" --lat 32.22 --lng -110.97 --csv locs.csv

Note that this requires Instagram cookies in order to work! See below for how to obtain one from your account.

Other output formats

Using the --json <output-location> command line argument, the list can be saved as a JSON file, almost identical to the raw API response.

Using the --geojson <output-location> command line argument, the list can be saved as a GeoJSON file for other geospatial applications.

Using the --ids <output-location> command line argument, all the found location IDs are output, suitable to pass into another tool, like instagram-scraper.

Using the --map <output-location> command line argument, a simple Leaflet map is made to visualize the locations of the returned points.

Multiple types of output can be generated. For example, the following command will search for Instagram locations, save the JSON list, a CSV file, and a map for viewing the locations visually.

instagram-location-search --cookie "<instagram-cookie>" --lat 32.22 --lng -110.97 --json locs.json --csv locs.csv --map map.html

Sample Usage with instagram-scraper

The ID list generated with the --ids flag can be passed into instagram-scraper to pull down image metadata.

Undocumented API

instagram-scraper relies on an undocumented API for the mobile apps. YMMV.

First, get the proximal location IDs of your target location:

instagram-location-search --cookies "<instagram-cookie>" --lat <lat> --lng <lng> --ids location_ids.txt

Be sure to install instagram-scraper:

pip install instagram-scraper

Location scraping requires an authenticated request. Save your creds in a local file:

echo "-u=<your username>" >> creds.txt
echo "-p=<your password>" >> creds.txt

Now use instagram-scraper to pull down all the photos at those locations:

instagram-scraper @creds.txt --filename @location_ids.txt --location --include-location --destination <output dir>

Getting Instagram cookies

Improved Tool Usage Process

The updated process allows you to obtain cookies through a pop-up browser window. To use this new flow, simply omit the --cookie parameter when running the command.

Important: An Instagram session ID should be treated like a password, as it provides full access to your Instagram account. Using this session ID in multiple places or on multiple computers may cause Instagram to invalidate all session IDs. Using this session ID for any purpose other than the official Instagram website or application may violate the Instagram Terms of Service and could lead to account suspension.

Follow these steps to use the improved tool usage process:

  1. Run the command without the --cookie parameter.
  2. In the opened Google Chrome instance, create a new profile.

Click “Continue without email”.

Enter a name for the profile you’d like to link to instagram account, and click “Done”.

Select “Only allow essential cookies”.

Log in to your Instagram account. The browser will close automatically shortly afterward.

Once you’ve completed the initial setup, you can simply click on the created profile in subsequent runs to use the associated Instagram account.

Old flow

This now requires the entire cookie string, in the format of an HTTP request header. Details TK.

Important: an Instagram session ID should be treated like a password — it provides full access to the Instagram account. Using this session ID in multiple places or on multiple computers may trigger Instagram to invalidate all session IDs. Using this session ID for any purpose other than the official Instagram website or application may be a violation of the Instagram Terms of Service and could lead to account suspension.

  1. In Google Chrome, log-in to Instagram.
  2. Right click on the page and press “Inspect” to bring up the Chrome Developer Tools.
  3. Click the “Application” tab in the Developer Tools Box.
  4. Under “Cookies” select “https://www.instagram.com.”
  1. Right click on any item and click “Show Requests With This Cookie”.
  2. Click on any request. In the “Headers” tab, scroll down to “Request Headers”.

Copy all text after “cookie: “. This is your cookie string. Replace <instagram-cookies> with this value when running instagram-location-search.

Tamil S

Tamil has a great interest in the fields of Cyber Security, OSINT, and CTF projects. Currently, he is deeply involved in researching and publishing various security tools with Kali Linux Tutorials, which is quite fascinating.

Recent Posts

Shadow-rs : Harnessing Rust’s Power For Kernel-Level Security Research

shadow-rs is a Windows kernel rootkit written in Rust, demonstrating advanced techniques for kernel manipulation…

2 weeks ago

ExecutePeFromPngViaLNK – Advanced Execution Of Embedded PE Files via PNG And LNK

Extract and execute a PE embedded within a PNG file using an LNK file. The…

3 weeks ago

Red Team Certification – A Comprehensive Guide To Advancing In Cybersecurity Operations

Embark on the journey of becoming a certified Red Team professional with our definitive guide.…

3 weeks ago

CVE-2024-5836 / CVE-2024-6778 : Chromium Sandbox Escape via Extension Exploits

This repository contains proof of concept exploits for CVE-2024-5836 and CVE-2024-6778, which are vulnerabilities within…

4 weeks ago

Rust BOFs – Unlocking New Potentials In Cobalt Strike

This took me like 4 days (+2 days for an update), but I got it…

4 weeks ago

MaLDAPtive – Pioneering LDAP SearchFilter Parsing And Security Framework

MaLDAPtive is a framework for LDAP SearchFilter parsing, obfuscation, deobfuscation and detection. Its foundation is…

4 weeks ago