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:
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.
: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-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
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.
-
In Google Chrome, log-in to Instagram.
-
Right click on the page and press "Inspect" to bring up the Chrome Developer Tools.
-
Click the "Application" tab in the Developer Tools Box.
-
Under "Cookies" select "https://www.instagram.com."
-
Right click on any item and click "Show Requests With This Cookie".
-
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 runninginstagram-location-search
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file instagram-location-search-1.2.0.tar.gz
.
File metadata
- Download URL: instagram-location-search-1.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c69a174630b9e94b0f0efe29d6d962eee56274bdd62161b504ac7c4f7f179e25 |
|
MD5 | c2e29a7c6186f2eb9ccd641492731c08 |
|
BLAKE2b-256 | c1efea5b887707ca116fd88f000ce0af49d6d00f384d43c3e3a65771381dfee5 |
File details
Details for the file instagram_location_search-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: instagram_location_search-1.2.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ede28a7eac81c47f9d1b735cea26b5ef9a5fa08ac2f69ceb70a2834ae782c10d |
|
MD5 | a2b9af2230cd14da9fc39f9fb6489c98 |
|
BLAKE2b-256 | 49b87f8f0ba0b8fdecfc537a69f15a8cfe71fe7610cfe2371b2c6cb148226be4 |