Last active
November 23, 2024 23:39
-
-
Save asid21/92332bac76a6a72954c69e655834619a to your computer and use it in GitHub Desktop.
Get all follower list on Twitter
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
| #!/usr/bin/env python3 | |
| import re | |
| import urllib.parse | |
| import urllib.request | |
| def getlist(cursor,userid): | |
| url = 'https://api.twitter.com/1.1/followers/list.json?include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&skip_status=1&cursor='+cursor+'&user_id='+userid+'&count=20' | |
| user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' | |
| headers = { | |
| 'User-Agent':user_agent, | |
| 'authorization':<twitter authorization>, | |
| 'cookie':<twitter cookie>, | |
| 'x-twitter-active-user':'yes', | |
| 'x-twitter-auth-type':'OAuth2Session', | |
| 'x-twitter-client-language':'ja' | |
| } | |
| req = urllib.request.Request(url, headers=headers) | |
| return req | |
| if __name__ == '__main__': | |
| flag = True; cursor = "-1"; old_cursor = "-1" | |
| userid = input('Target user id: ') | |
| while flag: | |
| response = urllib.request.urlopen(getlist(cursor,userid)) | |
| the_page = response.read() | |
| print(the_page) | |
| cursor = re.search(r'"next_cursor_str":"([0-9]*)"', str(the_page)).group(1) | |
| if cursor == old_cursor: | |
| flag = False | |
| else: | |
| old_cursor = cursor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment