do-me / fast-instagram-scraper

A fast Instagram Scraper based on Torpy.
33 stars 7 forks source link

Login required for locations as of 04/2022 #3

Closed do-me closed 2 years ago

do-me commented 3 years ago

After recent changes, the old endpoints, e.g.:

https://instagram.com/graphql/query/?query_hash=ac38b90f0f3981c42092016a37c59bf7&variables={"id":"<some_location_id>","first":50,"after":""}

seem not to work anymore.

However location IDs can still be mined successfully via a different endpoint:

https://www.instagram.com/explore/locations/<some_location_id>/?__a=1&max_id=<last_cursor>

Currently don't have time to investigate further but this quick fix works for me:

  1. Change lines 47-49 to:
    if location_or_hashtag == "location":
        instalink = 'https://www.instagram.com/explore/locations/' + str(object_id_or_string) + '/?__a=1&max_id=' + cursor 
        return instalink
  2. Due to different JSON respone replace all idata["data"] with idata["graphql"].

Same applies to hashtags. Just updated the code so hashtags can be mined again.

arifluthfi16 commented 2 years ago

Hey man, this is an appreciation comment of how amazing this implementation is :D thank you very much i learned a lot!

This repo is definitely underrated!

do-me commented 2 years ago

Locations cannot be retrieved anymore without login. Hashtags as of 04/2022 still do work without login but seldomly in TOR (you must be lucky to hit a good endpoint), e.g.

but it might be only a matter of time until it's going to be closed entirely (without login).

However, posts seem to be consistently publicly available (maybe even for a longer time to positive Instagram SEO). Hence, I propose

  1. Mining location or hashtag sites with Instagram Scraper with login (at a reduced pace obviously).
  2. If needed re-mine single posts with fast-instagram-scraper but in a tweaked version for posts only. This would require some slight changes which are not implemented yet.

I described it here as well.

do-me commented 2 years ago

Works again for some reason, test e.g. here. Closing for now.