diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a4a85a8 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index abffe3b..151e9fe 100644 --- a/README.md +++ b/README.md @@ -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 "" --lat 32.22 --lng -110.97 --csv locs.csv``` +```instagram_locations --cookie "" --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 ` 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 "" --lat 32.22 --lng -110.97 --json locs.json --csv locs.csv --map map.html``` +```instagram_locations --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 "" --lat --lng --ids location_ids.txt +instagram_locations --cookies "" --lat --lng --ids location_ids.txt ``` Be sure to install `instagram-scraper`: diff --git a/instagram_locations/__init__.py b/instagram_locations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/instagram-locations.py b/instagram_locations/instagram_locations.py similarity index 99% rename from instagram-locations.py rename to instagram_locations/instagram_locations.py index 4323bac..3029251 100644 --- a/instagram-locations.py +++ b/instagram_locations/instagram_locations.py @@ -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() + \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7feb055 --- /dev/null +++ b/setup.py @@ -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", + ] + }, +)