twscrape/_get_gql_ops.py
2023-09-08 20:47:13 +03:00

28 строки
598 B
Python

import httpx
# update this url on next run
# url = "https://abs.twimg.com/responsive-web/client-web/api.f4ff3bfa.js"
url = "https://abs.twimg.com/responsive-web/client-web/api.bb81931a.js"
script = httpx.get(url).text
ops = """
SearchTimeline
UserByRestId
UserByScreenName
TweetDetail
Followers
Following
Retweeters
Favoriters
UserTweets
UserTweetsAndReplies
ListLatestTweetsTimeline
"""
ops = [op.strip() for op in ops.split("\n") if op.strip()]
for x in ops:
idx = script.split(f'operationName:"{x}"')[0].split("queryId:")[-1]
idx = idx.strip('",')
print(f'OP_{x} = "{idx}/{x}"')