mirror of
https://github.com/bellingcat/instagram-location-search.git
synced 2026-06-12 20:38:30 +03:00
Add CSV output option
This commit is contained in:
@@ -14,15 +14,17 @@ Note that this requires an Instagram session ID in order to work! See below for
|
||||
|
||||
### Other output formats
|
||||
|
||||
Using the `--csv <output-location>` command line argument, the list can be saved as a CSV file.
|
||||
|
||||
Using the `--geojson <output-location>` command line argument, the list can be saved as a GeoJSON file for other geospatial applications.
|
||||
|
||||
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 GeoJSON file, and a map for viewing the locations visually.
|
||||
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 --session "3888090946%3AhdKd2fA8d72dqD%3A16" --lat 32.22 --lng -110.97 --json locs.json --geojson locs.geojson --map map.html```
|
||||
```python3 instagram-locations.py --session "3888090946%3AhdKd2fA8d72dqD%3A16" --lat 32.22 --lng -110.97 --json locs.json --csv locs.csv --map map.html```
|
||||
|
||||
## Getting an Instagram session ID
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import requests
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import argparse
|
||||
import json
|
||||
from string import Template
|
||||
@@ -117,6 +118,7 @@ def main():
|
||||
parser.add_argument("--json", action="store", dest="output")
|
||||
parser.add_argument("--geojson", action="store", dest="geojson")
|
||||
parser.add_argument("--map", action="store", dest="map")
|
||||
parser.add_argument("--csv", action="store", dest="csv")
|
||||
parser.add_argument("--lat", action="store", dest="lat")
|
||||
parser.add_argument("--lng", action="store", dest="lng")
|
||||
|
||||
@@ -140,6 +142,11 @@ def main():
|
||||
f.write(viz)
|
||||
f.close()
|
||||
|
||||
if (args.csv):
|
||||
df = pd.DataFrame(locations)
|
||||
df['url'] = df['external_id'].apply(lambda v: 'https://www.instagram.com/explore/locations/' + str(v))
|
||||
df.to_csv(args.csv)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user