Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import json
- import shlex
- import os
- import urllib
- from urllib.parse import quote
- from datetime import datetime
- """
- INSTRUCTIONS
- you have to change the csrf token and probably the cookies too
- """
- bookmarks_command_first_line = "curl --compressed 'https://x.com/i/api/graphql/XXX/Following?variables=" + urllib.parse.quote("""{"userId":"XXX","count":20,"includePromotedContent":false}""") + "'" # REPLACE THE GRAPHQL AND THE USERID
- time = datetime.now().isoformat()[:-7]
- for x in range(20): # while True:
- # I took some of the cookies out. The format is -H plus the value in single quotes. You can find the values in the "network" tab in the browser
- bookmarks_command = bookmarks_command_first_line + """
- -H 'Accept: */*' \
- -H 'Accept-Encoding: gzip, deflate, br, zstd' \
- -H 'Accept-Language: en-US,en;q=0.5' \
- -d '{"features":{"graphql_timeline_v2_bookmark_timeline":true,"rweb_tipjar_consumption_enabled":true,"responsive_web_graphql_exclude_directive_enabled":true,"verified_phone_label_enabled":false,"creator_subscriptions_tweet_preview_api_enabled":true,"responsive_web_graphql_timeline_navigation_enabled":true,"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,"communities_web_enable_tweet_community_results_fetch":true,"c9s_tweet_anatomy_moderator_badge_enabled":true,"articles_preview_enabled":true,"tweetypie_unmention_optimization_enabled":true,"responsive_web_edit_tweet_api_enabled":true,"graphql_is_translatable_rweb_tweet_is_translatable_enabled":true,"view_counts_everywhere_api_enabled":true,"longform_notetweets_consumption_enabled":true,"responsive_web_twitter_article_tweet_consumption_enabled":true,"tweet_awards_web_tipping_enabled":false,"creator_subscriptions_quote_tweet_preview_enabled":false,"freedom_of_speech_not_reach_fetch_enabled":true,"standardized_nudges_misinfo":true,"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":true,"rweb_video_timestamps_enabled":true,"longform_notetweets_rich_text_read_enabled":true,"longform_notetweets_inline_media_enabled":true,"responsive_web_enhance_cards_enabled":false}}'
- """
- print('faggot')
- print(bookmarks_command)
- bookmarks_command_split = shlex.split(bookmarks_command)
- subprocess.run(bookmarks_command_split)
- process = subprocess.Popen(bookmarks_command_split, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
- stdout, stderr = process.communicate()
- with open(os.path.join('following_outputs', f'{time}.txt'), 'a') as file:
- file.write(str(stdout) + '\n')
- try:
- bottom_cursor = json.loads(stdout)["data"]["user"]["result"]["timeline"]["timeline"]["instructions"][0]["entries"][-2]["content"]["value"] # the numbers could also be 1 and something thats slightly off
- except (IndexError, KeyError, json.JSONDecodeError) as e:
- bottom_cursor = json.loads(stdout)["data"]["user"]["result"]["timeline"]["timeline"]["instructions"][2]["entries"][-2]["content"]["value"] # the numbers could also be 1 and something thats slightly off
- print("waiting 2 seconds...")
- process.wait(2)
- bookmarks_command_first_line = "curl --compressed 'https://x.com/i/api/graphql/XXX/Following?variables=" + urllib.parse.quote(f'{{"userId":"XXX","count":20,"cursor":"{bottom_cursor}","includePromotedContent":false}}') + "'" # replace user id and xxx
- #%7B%22count%22%3A20%2C%22includePromotedContent%22%3Atrue%2C%22cursor%22%3A%22{encoded_cursor}%22%7D'" )
Add Comment
Please, Sign In to add comment