-
-
Save HumanG33k/b457310defb6a23b1d0914b7e259a2a8 to your computer and use it in GitHub Desktop.
Fetch Twitter following list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, re, sys | |
url = "https://mobile.twitter.com/{}/following" | |
cursor = "" | |
usernames = [] | |
first = True | |
if len(sys.argv) < 2: | |
print("Usage: python followers.py <username>") | |
quit(1) | |
while True: | |
u = url.format(sys.argv[1]) | |
if not first: | |
u += "?cursor={}".format(cursor) | |
first = False | |
req = requests.get(u) | |
users = re.findall(r"@[^>]+>(.+)</s.+", req.text) | |
usernames.extend(users) | |
c = re.search(r"cursor=([0-9]+)", req.text) | |
if c is not None: | |
cursor = c.groups(0)[0] | |
print(cursor) | |
else: | |
break | |
print(",".join(usernames)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment