instagram-location-search


Nameinstagram-location-search JSON
Version 1.5.2 PyPI version JSON
download
home_pagehttps://www.bellingcat.com
SummaryFinds Instagram location IDs near a specified latitude and longitude.
upload_time2024-04-09 12:13:10
maintainerNone
docs_urlNone
authorBellingcat
requires_pythonNone
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Instagram Location Search

[![PyPI version](https://badge.fury.io/py/instagram-location-search.svg)](https://badge.fury.io/py/instagram-location-search)
## Installation
This Python application can be installed from [PyPI](https://pypi.org/project/instagram-location-search/) 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](https://github.com/arc298/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](docs/map-example.png)

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:
```sh
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:
```sh
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:
```sh
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](docs/selenium1.png)
3. Click "Continue without email".
   ![Continue without email](docs/selenium2.png)
4. Enter a name for the profile you'd like to link to instagram account, and click "Done".
   ![Creating an account](docs/selenium3.png)
5. Select "Only allow essential cookies".
   ![Only allow essential cookies](docs/selenium4.png)
6. Log in to your Instagram account. The browser will close automatically shortly afterward.
   ![Log in to Instagram](docs/selenium5.png)

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](docs/cookies.jpg)

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](docs/cookies2.png)

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.bellingcat.com",
    "name": "instagram-location-search",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Bellingcat",
    "author_email": "tech@bellingcat.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/39/80d56e1200836423b31c1850d32f75fc537e161cef9c014c1dc6353dba33/instagram-location-search-1.5.2.tar.gz",
    "platform": null,
    "description": "# Instagram Location Search\n\n[![PyPI version](https://badge.fury.io/py/instagram-location-search.svg)](https://badge.fury.io/py/instagram-location-search)\n## Installation\nThis Python application can be installed from [PyPI](https://pypi.org/project/instagram-location-search/) using pip:\n`pip install instagram-location-search`\n\nor the latest from the repo:\n`pip install git+https://github.com/bellingcat/instagram-location-search`\n\n## Example usage\n\nThe 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\".\n\n```instagram-location-search --cookie \"<instagram-cookies>\" --lat 32.22 --lng -110.97 --csv locs.csv```\n\nNote that this requires Instagram cookies in order to work! See below for how to obtain one from your account.\n\n### Other output formats\n\nUsing the `--json <output-location>` command line argument, the list can be saved as a JSON file, almost identical to the raw API response.\n\nUsing the `--geojson <output-location>` command line argument, the list can be saved as a GeoJSON file for other geospatial applications.\n\nUsing the `--ids <output-location>` command line argument, all the found location IDs are output, suitable to pass into another tool, like [instagram-scraper](https://github.com/arc298/instagram-scraper).\n\nUsing the `--map <output-location>` command line argument, a simple Leaflet map is made to visualize the locations of the returned points.\n\n![Example of map visualization](docs/map-example.png)\n\nMultiple 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.\n\n```instagram-location-search --cookie \"<instagram-cookie>\" --lat 32.22 --lng -110.97 --json locs.json --csv locs.csv --map map.html```\n\n## Sample Usage with `instagram-scraper`\nThe ID list generated with the `--ids` flag can be passed into `instagram-scraper` to pull down image metadata.\n\n### :rotating_light: Undocumented API :rotating_light:\n`instagram-scraper` relies on an undocumented API for the mobile apps. YMMV.\n\nFirst, get the proximal location IDs of your target location:\n```sh\ninstagram-location-search --cookies \"<instagram-cookie>\" --lat <lat> --lng <lng> --ids location_ids.txt\n```\n\nBe sure to install `instagram-scraper`:\n```\npip install instagram-scraper\n```\n\nLocation scraping requires an authenticated request. Save your creds in a local file:\n```sh\necho \"-u=<your username>\" >> creds.txt\necho \"-p=<your password>\" >> creds.txt\n```\n\nNow use `instagram-scraper` to pull down all the photos at those locations:\n```sh\ninstagram-scraper @creds.txt --filename @location_ids.txt --location --include-location --destination <output dir>\n```\n\n## Getting Instagram cookies\n\n### Improved Tool Usage Process\n\nThe 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.\n\n__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.__\n\nFollow these steps to use the improved tool usage process:\n\n1. Run the command without the `--cookie` parameter.\n2. In the opened Google Chrome instance, create a new profile.\n   ![Creating a new profile](docs/selenium1.png)\n3. Click \"Continue without email\".\n   ![Continue without email](docs/selenium2.png)\n4. Enter a name for the profile you'd like to link to instagram account, and click \"Done\".\n   ![Creating an account](docs/selenium3.png)\n5. Select \"Only allow essential cookies\".\n   ![Only allow essential cookies](docs/selenium4.png)\n6. Log in to your Instagram account. The browser will close automatically shortly afterward.\n   ![Log in to Instagram](docs/selenium5.png)\n\nOnce you've completed the initial setup, you can simply click on the created profile in subsequent runs to use the associated Instagram account.\n\n\n### Old flow\nThis now requires the entire cookie string, in the format of an HTTP request header. Details TK.\n\n__Important: an Instagram session ID should be treated like a password \u2014 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.__\n\n1. In Google Chrome, log-in to Instagram.\n2. Right click on the page and press \"Inspect\" to bring up the Chrome Developer Tools.\n3. Click the \"Application\" tab in the Developer Tools Box.\n4. Under \"Cookies\" select \"https://www.instagram.com.\"\n![Finding the Instagram cookie](docs/cookies.jpg)\n\n5. Right click on any item and click \"Show Requests With This Cookie\".\n6. Click on any request. In the \"Headers\" tab, scroll down to \"Request Headers\".\n\n![Finding the full cookie string](docs/cookies2.png)\n\n7. Copy all text after \"cookie: \". This is your cookie string. Replace `<instagram-cookies>` with this value when running `instagram-location-search`.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Finds Instagram location IDs near a specified latitude and longitude.",
    "version": "1.5.2",
    "project_urls": {
        "Homepage": "https://www.bellingcat.com"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdab73884720153584b838b46e5d5fc1dbb5ba1a04b0ea6fb99c130001fff6cd",
                "md5": "80ce353ab125443320d18f77612138e4",
                "sha256": "2bf25f941ae463d2333229ff4cd88906d752de1027d18805932192d3a460f319"
            },
            "downloads": -1,
            "filename": "instagram_location_search-1.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80ce353ab125443320d18f77612138e4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9143,
            "upload_time": "2024-04-09T12:13:09",
            "upload_time_iso_8601": "2024-04-09T12:13:09.265133Z",
            "url": "https://files.pythonhosted.org/packages/bd/ab/73884720153584b838b46e5d5fc1dbb5ba1a04b0ea6fb99c130001fff6cd/instagram_location_search-1.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c3980d56e1200836423b31c1850d32f75fc537e161cef9c014c1dc6353dba33",
                "md5": "7125d054aacc5c9705f88733a1408aef",
                "sha256": "d657904b908ceb4c2c9f180ed3f8775f2ca8b288f149240c15b71c8ffa8c042c"
            },
            "downloads": -1,
            "filename": "instagram-location-search-1.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7125d054aacc5c9705f88733a1408aef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8409,
            "upload_time": "2024-04-09T12:13:10",
            "upload_time_iso_8601": "2024-04-09T12:13:10.892611Z",
            "url": "https://files.pythonhosted.org/packages/6c/39/80d56e1200836423b31c1850d32f75fc537e161cef9c014c1dc6353dba33/instagram-location-search-1.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 12:13:10",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "instagram-location-search"
}
        
Elapsed time: 0.21711s