mahrtayyab / tweety

Twitter Scraper
460 stars 62 forks source link

Get all followers for a user #200

Open narodnik opened 1 month ago

narodnik commented 1 month ago

This code will only print the first page:

app = Twitter("session")
app.sign_in(username, password)

user = app.get_user_info(username)
users = app.iter_user_followers(username, pages=4)

i = 0
for x in users:
    self_user, followers = x
    print(f"Page {i}")
    for follower in followers:
        print(" ", follower.username, follower.followers_count)
    print()

    if i > 5:
        break
    i += 1
mahrtayyab commented 1 month ago

Example code is working okay for me, can you please share the username

narodnik commented 1 month ago

Narodism, for me it just prints a single page then exits.

mahrtayyab commented 1 month ago

image

narodnik commented 1 month ago

Hmm I'm not sure what's up. I tried running the script again, and now I get:

$ ./follow.py 
Traceback (most recent call last):
  File "/home/narodnik/src/stuff/twat/follows/./follow.py", line 10, in <module>
    app.sign_in(username, password)
  File "/home/narodnik/.local/lib/python3.12/site-packages/tweety/auth.py", line 111, in sign_in
    return self._login()
           ^^^^^^^^^^^^^
  File "/home/narodnik/.local/lib/python3.12/site-packages/tweety/auth.py", line 198, in _login
    raise DeniedLogin(response=response, message=reason)
tweety.exceptions.DeniedLogin: Suspicious login prevented. We blocked an attempt to access your account because we weren't sure it was really you.

This happens when we notice unusual login activity, like an attempt to log in too many times, or from a different location or device.

You'll need to wait before trying to log in again. Some blocks are removed automatically.

Get help with login issues.
mahrtayyab commented 3 weeks ago

201