twscrape/_get_gql_ops.py
2023-07-15 02:25:49 +03:00

27 строки
524 B
Python

import httpx
# update this url on next run
url = "https://abs.twimg.com/responsive-web/client-web/api.f4ff3bfa.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}"')