INNER CODE UNIT · Python

parse_fetch

Far-Se/tabame · plugins/api-client/main.py:570

def parse_fetch(text):
    m = re.search(r'fetch\(\s*["\']([^"\']+)["\']', text)
    if not m:
        return None
    url = m.group(1)
    method, headers, body_raw = "GET", {}, None
    brace_idx = text.find("{", m.end())
    if brace_idx != -1:
        obj_text = _extract_balanced(text, brace_idx)
        if obj_text:
            cleaned = re.sub(r",\s*([}\]])", r"\1", obj_text)
            try:
                opts = json.loads(cleaned)
            except Exception:
                opts = {}
            method = (opts.get("method") or "GET").upper()
            headers = dict(opts.get("headers") or {})
            body_raw = opts.get("body")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…