diezo / Ensta

🔥 Fast & Reliable Python Package For Instagram API - 2024
https://bit.ly/ensta-discord
MIT License
355 stars 41 forks source link

NetworkError("HTTP response doesn't include 'status' or 'users' node." when making list of followers #68

Closed TastingSunsets closed 7 months ago

TastingSunsets commented 8 months ago

Hi

I am trying to create a list of the followers of another public account (which I am following with the account I use to run the script). The target account has 3k+ followers, but I only ever manage to write about 2k followers to a .txt file. The code I am using is this:

from ensta import Host

host = Host("username", "password")

followers = host.followers("target_account_id", count=0)

with open("followers.txt", "w") as file:
    for user in followers:
        if user is not None and user.username is not None:
            file.write(user.username + "\n")
        else:
            file.write("\n")

The error I am getting is this one:

Traceback (most recent call last): File "/Users/tasting.sunsets/sandbox/ensta/followers.py", line 8, in for user in followers: File "/opt/homebrew/lib/python3.11/site-packages/ensta/SessionHost.py", line 319, in followers raise NetworkError("HTTP response doesn't include 'status' or 'users' node.") ensta.lib.Exceptions.NetworkError: HTTP response doesn't include 'status' or 'users' node.

Any suggestions? Thanks!

diezo commented 8 months ago

You're being rate limited. You should wait for a while before trying again.

I'm working on a cursor feature by which you'll be able to continue scraping the followers list where you left off the previous time.

TastingSunsets commented 8 months ago

Hmm yeah, thought so too since it prompts for a challenge when logging back in after this error pops up. The thing is, the error pops up even if it's the first run in over 36hrs... So looks like it rate limits me anyways since the amount of followers is too big, no? It errors at 2100 followers, which looks to be a cap of 60 requests if I read your documentation right (35 usernames per request). The cursor feature would be a great addition, any other tips or suggestions you have that might help me to proceed with my setup? Starred by the way, great project!

diezo commented 7 months ago

thanks for the star. i'll add the cursor feature soon. in the meantime, you should take precautions like adding time intervals between requests, using the same session as stored in ensta-session.txt file until it expires and the best way is to use dummy accounts and not your main account. note that creating bot accounts may be against instagram's policies. so do check them before proceeding.