• Stars
    star
    548
  • Rank 81,119 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Finds Instagram location IDs near a specified latitude and longitude.

Instagram Location Search

PyPI version

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.

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-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. Creating a new profile
  3. Click "Continue without email". Continue without email
  4. Enter a name for the profile you'd like to link to instagram account, and click "Done". Creating an account
  5. Select "Only allow essential cookies". Only allow essential cookies
  6. Log in to your Instagram account. The browser will close automatically shortly afterward. Log in to Instagram

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

More Repositories

1

octosuite

GitHub Data Analysis Framework.
Python
1,786
star
2

telegram-phone-number-checker

Check if phone numbers are connected to Telegram accounts.
Python
1,056
star
3

auto-archiver

Automatically archive links to videos, images, and social media content from Google Sheets (and more).
Python
532
star
4

sar-interference-tracker

A Google Earth Engine tool for identifying satellite radar interference.
JavaScript
519
star
5

open-questions

Want to contribute? These are difficult, long-term projects that could be valuable to open source investigators at Bellingcat and around the world.
Jupyter Notebook
328
star
6

tiktok-hashtag-analysis

Provides tools to analyze hashtags within posts scraped from TikTok.
Python
298
star
7

ukraine-timemap

TimeMap instance for Civilian Harm in Ukraine
JavaScript
243
star
8

ShadowFinder

Find possible locations of shadows around the world
Python
223
star
9

open-source-research-notebooks

Jupyter notebooks helping open source researchers, journalists, and fact-checkers use command line tools and code projects for digital investigations.
Jupyter Notebook
195
star
10

wayback-google-analytics

A lightweight tool for scraping current and historic Google Analytics data
Python
181
star
11

osm-search

A user friendly way to search OpenStreetMap data for features in proximity to each other.
Vue
161
star
12

EDGAR

Tool for the retrieval of corporate and financial data from the SEC
Python
105
star
13

reddit-post-scraping-tool

Given a subreddit name and a keyword, this program returns all top (by default) posts that contain the specified keyword.
Visual Basic .NET
80
star
14

whisperbox-transcribe

Easy to deploy API for transcribing and translating audio / video using OpenAI's whisper model.
Python
59
star
15

cloud-free-subregion

Google Earth Engine application that finds Sentinel-2 images that are cloud-free in a particular area of interest.
JavaScript
54
star
16

tiktok-timestamp

A tiny client side tool that retrieves the timestamp from Tiktok videos.
HTML
45
star
17

name-variant-search

A tool for searching common variations of a human name
JavaScript
40
star
18

vk-url-scraper

Scrape VK URLs to fetch info and media - python API or command line tool.
Python
40
star
19

knewkarma

A Reddit data analysis toolkit
Python
39
star
20

avoc

Working repo for the 2024 Bellingcat Tech Fellowship.
CSS
36
star
21

geoclustering

Command-line tool for clustering geolocations πŸ“
Python
30
star
22

uniform-timezone

Extension to standardize dates and times to the same timezone across social media websites.
JavaScript
30
star
23

facebook-downloader

Facebook video downloader
Python
26
star
24

twitter-geocode-searches

Analysis for "Geofenced Searches on Twitter: A Case Study Detailing South Asia’s Covid Crisis", published on May 19, 2021.
HTML
24
star
25

RS4OSINT

Guide to Remote Sensing for OSINT
TeX
23
star
26

google-apps-script

A collection of handy Google Apps Script code snippets
JavaScript
21
star
27

telegram-group-joiner

Online tool to automatically join public/private telegram groups.
JavaScript
18
star
28

cisticola

Coordinates scrapers and interfaces with database
Python
17
star
29

youtube-comment-scraper

A script to scrape youtube comments and checks whether a user commented on all of the given videos
Python
17
star
30

alias-generator

Node module to generate likely aliases for a given human name
JavaScript
16
star
31

polyphemus

Scraper for Odysee: alt-tech platform for sharing video
Python
14
star
32

quitobaquito

Methodology for "The Disappearance of Quitobaquito Springs: Tracking Hydrologic Change with Google Earth Engine," published on October 1, 2020.
Jupyter Notebook
12
star
33

hackathon-submission-template

Template repository and README for submissions to Bellingcat's Global Hackathon
9
star
34

o9a-product-scripts

Scripts used in research for a Bellingcat article about the Order of Nine Angles
Python
6
star
35

likee-downloader

A program for downloading videos from Likee, given a username
Python
4
star
36

gesara-entity-viz

Generates an interactive visualisation of named entities in English-language posts archived in a database of Telegram channels that have posted about the GESARA conspiracy theory.
TypeScript
3
star
37

vis-tj-kg-map-2022

Interactive map for the Tajikistan-Kyrgyzstan Border Clash 2022
JavaScript
2
star
38

search-grid-generator

A Vue App for quickly generating KML Search Grids
Vue
2
star
39

smart-image-sorter

User friendly zero-shot image classification using open-source models from HuggingFace's library
Jupyter Notebook
2
star
40

coronavirus-aid-data

Data for "What Restaurants and Maps Can Tell us About Billions of Dollars of Covid-19 Relief Funds," published on December 4, 2020.
2
star
41

who-killed-abelardo

visualization of audios in map
Vue
1
star
42

.github

Community health files and organization profile for @bellingcat
1
star