Merge pull request #9 from rly0nheart/main

This commit is contained in:
Miguel Sozinho Ramalho
2023-02-13 15:07:07 +00:00
committed by GitHub
5 changed files with 50 additions and 10 deletions

11
Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
# syntax=docker/dockerfile:1
FROM python:latest
WORKDIR /app
COPY . .
RUN pip install --upgrade pip && pip install build && python -m build && pip install dist/*.whl
ENTRYPOINT ["instagram_locations"]

View File

@@ -1,14 +1,17 @@
# Instagram Location Search
## Prerequisites
This Python application requires `requests` to be properly installed. This can be done with `pip3 install requests`.
## 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".
```python3 instagram-locations.py --cookie "<instagram-cookies>" --lat 32.22 --lng -110.97 --csv 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.
@@ -26,7 +29,7 @@ Using the `--map <output-location>` command line argument, a simple Leaflet map
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.
```python3 instagram-locations.py --cookie "<instagram-cookie>" --lat 32.22 --lng -110.97 --json locs.json --csv locs.csv --map map.html```
```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.
@@ -36,7 +39,7 @@ The ID list generated with the `--ids` flag can be passed into `instagram-scrape
First, get the proximal location IDs of your target location:
```sh
python3 instagram-locations.py --cookies "<instagram-cookie>" --lat <lat> --lng <lng> --ids location_ids.txt
instagram_locations --cookies "<instagram-cookie>" --lat <lat> --lng <lng> --ids location_ids.txt
```
Be sure to install `instagram-scraper`:

View File

View File

@@ -231,7 +231,4 @@ def main():
ids = map(lambda loc: str(loc["external_id"]), locations)
with open(args.dump_ids, "w") as f:
f.write("\n".join(ids))
if __name__ == "__main__":
main()

29
setup.py Normal file
View File

@@ -0,0 +1,29 @@
import setuptools
with open("README.md", "r", encoding="utf-8") as file:
long_description = file.read()
setuptools.setup(
name="instagram-location-search",
version="1.0.0",
author="Bellingcat",
packages=["instagram_locations"],
description="Finds Instagram location IDs near a specified latitude and longitude.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://www.bellingcat.com",
license="MIT License",
install_requires=["requests", "instagram-scraper"],
classifiers=[
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Natural Language :: English',
'Programming Language :: Python :: 3'
],
entry_points={
"console_scripts": [
"instagram_locations=instagram_locations.instagram_locations:main",
]
},
)