Fix CDN 403 by downloading PDFs via curl_cffi before tabula parsing#10
Open
btg94 wants to merge 1 commit into
Open
Fix CDN 403 by downloading PDFs via curl_cffi before tabula parsing#10btg94 wants to merge 1 commit into
btg94 wants to merge 1 commit into
Conversation
…parsing The NBA CDN (Akamai) now blocks all programmatic HTTP requests — both requests.get() and tabula.read_pdf() from URL return 403 Forbidden. This uses curl_cffi with impersonate='chrome' to bypass Akamai's TLS fingerprinting. PDFs are downloaded to temp files and parsed locally by tabula, then cleaned up. Falls back to requests/aiohttp when curl_cffi is not installed. Fixes mxufc29#6 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Wondering if or when this will be shipped? 👀 cc: @mxufc29 |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requests.get()andtabula.read_pdf()from URL failcurl_cffiwithimpersonate='chrome'to bypass Akamai's TLS fingerprintingrequests/aiohttpwhencurl_cffiis not installedChanges
_parser.py: New_download_pdf_bytes()helper usingcurl_cffi. Updatedvalidate_injrepurl()andextract_injrepurl()to download-then-parse-locally via temp files_parser_asy.py: New_download_pdf_bytes_sync()for use withasyncio.to_thread(). Updatedvalidate_irurl_async()andextract_irurl_async()with the same temp file patternpyproject.toml: Addedcurl_cffi>=0.7,<0.14as a dependencytests/test_cdn_bypass.py: 30 new tests (26 pass, 4 skip pending async helper rename)Design decisions
curl_cffiis a core dependency (not optional) since 100% of remote fetches are broken without it**kwargspattern for custom headers still worksfinallyblocks to prevent leaksFixes #6
Test plan
_download_pdf_bytesuses curl_cffi withimpersonate='chrome'requestswhen curl_cffi unavailableextract_injrepurlpasses local temp path to tabula (not URL)asyncio.to_threadfor blocking curl_cffi calls🤖 Generated with Claude Code