MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / _cffi_get

Method _cffi_get

scripts/fetch_fulltext.py:97–110  ·  view source on GitHub ↗

Use curl-cffi with Chrome TLS impersonation, bypassing proxy for FDA. Akamai bot detection blocks requests from proxy/VPN IPs.

(url: str, timeout: int = 30, **kwargs)

Source from the content-addressed store, hash-verified

95
96 @staticmethod
97 def _cffi_get(url: str, timeout: int = 30, **kwargs) -> Optional[object]:
98 """Use curl-cffi with Chrome TLS impersonation, bypassing proxy for FDA.
99 Akamai bot detection blocks requests from proxy/VPN IPs.
100 """
101 if cffi_requests is not None:
102 saved = {k: os.environ.pop(k, None) for k in ("http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY", "all_proxy", "ALL_PROXY")}
103 try:
104 session = cffi_requests.Session(impersonate=FDAFetcher.IMPERSONATE)
105 return session.get(url, timeout=timeout, allow_redirects=True, **kwargs)
106 finally:
107 for k, v in saved.items():
108 if v is not None:
109 os.environ[k] = v
110 return requests.get(url, headers=REQUEST_HEADERS, timeout=timeout, allow_redirects=True, **kwargs)
111
112 @staticmethod
113 def discover_pdf_url(source_url: str) -> Optional[str]:

Callers 2

discover_pdf_urlMethod · 0.80
fetch_pdfMethod · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected