[Python] 纯文本查看 复制代码 import requests
# 定义 URL
url = "https://api.x.com/graphql/QGIw94L0abhuohrr76cSbw/UserByScreenName"
params = {
"variables": '{"screen_name":"leijun"}',
"features": '{"hidden_profile_subscriptions_enabled":true,"profile_label_improvements_pcf_label_in_post_enabled":false,"rweb_tipjar_consumption_enabled":true,"responsive_web_graphql_exclude_directive_enabled":true,"verified_phone_label_enabled":false,"subscriptions_verification_info_is_identity_verified_enabled":true,"subscriptions_verification_info_verified_since_enabled":true,"highlights_tweets_tab_ui_enabled":true,"responsive_web_twitter_article_notes_tab_enabled":true,"subscriptions_feature_can_gift_premium":true,"creator_subscriptions_tweet_preview_api_enabled":true,"responsive_web_graphql_skip_user_profile_image_extensions_enabled":false,"responsive_web_graphql_timeline_navigation_enabled":true}',
"fieldToggles": '{"withAuxiliaryUserLabels":false}',
}
# 定义请求头
headers = {
"Authorization": "Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",
"Content-Type": "application/json",
"Cookie": 'guest_id=173579937744290076; night_mode=2; guest_id_marketing=v1%3A173579937744290076; guest_id_ads=v1%3A173579937744290076; gt=1874704584381546528; personalization_id="v1_B6UMnzD8IXnNaEXvG6+CbQ=="',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"X-Client-Transaction-Id": "wYXKPeQ0XXH41KbvYrzoW89mqnet7RiEhWHF9iqM5sA/7Pd2e8WntGOBa22MO+6IDv4O58LtDVaG/8SF+dc53xBKY8/twg",
"X-Guest-Token": "1874704584381546528",
}
# 发起 GET 请求
response = requests.get(url, headers=headers, params=params)
# 打印结果
if response.status_code == 200:
print("Response JSON:", response.json())
else:
print(f"Error: {response.status_code}, Response Text: {response.text}")
python 的request库好像不需要 |