Skip to main content

Finds Instagram location IDs near a specified latitude and longitude.

Project description

Instagram Location Search

Installation

This Python application can be installed from PyPI using pip, and can also be built into a Docker image

Install with Pip

pip3 install git+https://github.com/bellingcat/instagram-location-search

Build Docker image

docker build 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_locations --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.

Example of map visualization

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_locations --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.

:rotating_light: Undocumented API :rotating_light:

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

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

instagram_locations --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

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." Finding the Instagram cookie

  5. Right click on any item and click "Show Requests With This Cookie".

  6. Click on any request. In the "Headers" tab, scroll down to "Request Headers".

Finding the full cookie string

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instagram-location-search-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file instagram-location-search-1.0.0.tar.gz.

File metadata

File hashes

Hashes for instagram-location-search-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a339dd8561a59fd6d8e98b5b953c314a6fcde09b1d00a5ba4b121e3c585c1862
MD5 eb07d55b6ade2e765792ff670e5cc3d8
BLAKE2b-256 1dba4ecc784d5caa454a29010e0654651bc2412485cc577d4af382147d7994de

See more details on using hashes here.

File details

Details for the file instagram_location_search-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for instagram_location_search-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc9adda8fee7969ea8311de05ea81735c6c747ce0f2f88fff765e15f01cccc1a
MD5 ff7400031bae07370f902f1bc8fc2d99
BLAKE2b-256 50be314c40fb01368033cad3db24d5f496eb6912a651dc40179f19c0cfd0d2dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page