Guest User

Untitled

a guest
Oct 30th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.49 KB | None | 0 0
  1. import subprocess
  2. import json
  3. import shlex
  4. import os
  5. import urllib
  6. from urllib.parse import quote
  7. from datetime import datetime
  8.  
  9. """
  10. INSTRUCTIONS
  11. you have to change the csrf token and probably the cookies too
  12. """
  13.  
  14. 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
  15. time = datetime.now().isoformat()[:-7]
  16.  
  17. for x in range(20): # while True:
  18.  
  19.     # 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
  20.     bookmarks_command = bookmarks_command_first_line + """
  21.        -H 'Accept: */*' \
  22.        -H 'Accept-Encoding: gzip, deflate, br, zstd' \
  23.        -H 'Accept-Language: en-US,en;q=0.5' \
  24.        -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}}'
  25.    """
  26.  
  27.     print('faggot')
  28.     print(bookmarks_command)
  29.  
  30.     bookmarks_command_split = shlex.split(bookmarks_command)
  31.     subprocess.run(bookmarks_command_split)
  32.  
  33.     process = subprocess.Popen(bookmarks_command_split, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
  34.     stdout, stderr = process.communicate()
  35.  
  36.     with open(os.path.join('following_outputs', f'{time}.txt'), 'a') as file:
  37.         file.write(str(stdout) + '\n')  
  38.  
  39.     try:
  40.         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
  41.     except (IndexError, KeyError, json.JSONDecodeError) as e:
  42.         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        
  43.  
  44.     print("waiting 2 seconds...")
  45.    
  46.     process.wait(2)
  47.    
  48.     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
  49.     #%7B%22count%22%3A20%2C%22includePromotedContent%22%3Atrue%2C%22cursor%22%3A%22{encoded_cursor}%22%7D'"  )
  50.  
  51.  
Add Comment
Please, Sign In to add comment