-
-
Save gregorycoleman/40d4b1e6e126754f5b1788aada84988c to your computer and use it in GitHub Desktop.
Fetch Twitter following list
This file contains 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