Instagram location search is a lightweight Python script with several data. This enables the
analysts to search for Instagram locations depending on the provided coordinates. However,
this tool doesn’t require users’ Instagram credentials but employs session-id-token.
Employing this tool is very easy, requiring the command python3 Instagram-
location.py—session “<session-id-token>.”
The output which users obtain is available in four different options:
- JSON: It requires
the –json command. This will then provide a list of a JSON file which
is also similar to the unstructured API response.
- GEOJSON: It
requires the –geojson command. It will provide the list of locations as
per the GEOJSON file.
- We can scrape
location ids and save them within a .txt file by introducing the
command –id. This passes through another Instagram media scraper.
- Using the command
–map, map-based locations are achieved.
Scraping and visualizing several hundreds of locations is done using the Actowiz scraping
tool for Instagram locations. Not only locations but entire Instagram data gets scraped
without any authentication needs easily.
Scraping data without authentications and tokens
The aim is to get JSON data directly from websites instead of HTML pages. First, you need to
filter all posts from a particular area. For example, search by the most suitable tag like
#moscow, #russiaa, or anything you want. Now, open a page for tag #russia:
https://www.instagram.com/explore/tags/russia/
At the end of the URL, now add “?__a=1”. This will come out like this:
https://www.instagram.com/explore/tag/russia/?__a=1
From 73 posts, we have obtained JSON data with tag #russia from approx. 50M. So, the
question is, how are they received?
Let’s understand the steps
Step 1:
First, scrape all posts having a specific tag
Then, scrape all the data. To achieve this, we require the id of the following
page, which is
equal to the end_cursor parameter:
graphql > hashtag > edge_hashtag_to_media > page_info > end_cursor
We then add the request as max_id:
https://www.instagram.com/explore/tags/russia/?__a=1&max_id=end_cursor
You can get the python script like this:
The script above is for the first five pages and is saved to JSON in the recent directory.
Tag and page count can be changed per requirement using tag and page_count.
Step 2: Scraping Instagram Locations
Here scraping is done using shortcode, a combination of letters and numbers. The URL
structure is: https://www.instagram.com/p/shortcode/
Location scraping uses the same method:
By using the first 206 posts, we get some locations with the tag #russia
In the above script, you may find some locations irrelevant. But you can fix it using geo
position and post language.
Conclusion:
Thus, several reasons why Instagram location search is essential. Undoubtedly,
it is easy to install and deploy and delivers effective results. The best part is that it
easily
integrates with other scrapers.
For more information, contact Actowiz Solutions now! You can also reach us for all your mobile app scraping and web scraping services requirements.