ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.94k stars 608 forks source link

Increase the number of results for method feed_tag #371

Closed mattiabaldari closed 2 years ago

mattiabaldari commented 2 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Which client are you using?


Describe your Question/Issue:

I'm trying to extract a set of posts under a certain hashtag. In order to do so I'm using the following function "feed_tag", but I do not find a way to specify HOW MANY posts I want to get. I tried with the variable "count" as per other functions, but it doesn't seems to work. Can you tell me if there is a way?


Paste the output of python -V here:

Code:

api = Client(user_name, password)
api.feed_tag(hashtag, rank_token)
mattiabaldari commented 2 years ago

I found a way thanks to @MaximBoyarskiy within issue number #297. The solution is to use max_id=results['next_max_id'] within the feed_tag parameters.

    while has_more and len(items) < posts_number:
        if "results" in locals():
            results = api.feed_tag(hashtag, rank_token, max_id=results['next_max_id'])
        else:
            results = api.feed_tag(hashtag, rank_token)
        items.extend(results.get('items', []))
        has_more = results.get('more_available')