INNER CODE UNIT · Python

get_js_files

trevorhobenshield/twitter-api-client · scripts/update.py:185

def get_js_files(r: Response, out: Path = JS_FILES) -> None:
    endpoints = _get_endpoints(r)
    csp = sorted({x.strip(';') for x in r.headers.get("content-security-policy").split() if x.startswith("https://")})
    PATH_URLS.write_text('\n'.join(csp))
    urls = [
        f'{_base}/{k}.{v}{_a}'
        for k, v in endpoints.items()
        if not re.search(r'participantreaction|\.countries-|emojipicker|i18n|icons\/', k, flags=re.I)
    ]
    asyncio.run(process(download(urls, out=out), desc='Downloading JS files'))


def parse_matches(matches: list[tuple]) -> dict:
    d = {}
    for m in matches:
        d[m[1]] = {
            "queryId": m[0],
            "operationName": m[1],

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…