INNER CODE UNIT · Python
parse_matches
trevorhobenshield/twitter-api-client · scripts/update.py:197
def parse_matches(matches: list[tuple]) -> dict:
d = {}
for m in matches:
d[m[1]] = {
"queryId": m[0],
"operationName": m[1],
"operationType": m[2],
"featureSwitches": sorted(re.sub(r'[\s"\']', '', x) for x in (m[3].split(',') if m[3] else [])),
"fieldToggles": sorted(re.sub(r'[\s"\']', '', x) for x in (m[4].split(',') if m[4] else []))
}
return d
def main():
client = Client(headers={'user-agent': random.choice(USER_AGENTS)}, follow_redirects=True, http2=True)
r1 = client.get('https://x.com')
PATH_HOMEPAGE.write_text(r1.text)