Fixed cloudflare fetch#292
Open
IJIJI wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to improve scraping/fetching reliability for Cloudflare-protected supplier endpoints (notably LCSC/Digi-Key) and make the LCSC API “test” check less brittle against upstream text changes.
Changes:
- Add a Cloudflare-aware fallback path in
download()by retrying API fetches viacloudscraper. - Adjust LCSC
test_api()expectations to rely on stable identity fields plus a loose check on the free-text description. - Regenerate
poetry.lock(Poetry 2.4.1) and update.gitignoreentries.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
kintree/common/tools.py |
Adds cloudscraper helper and introduces a requests→cloudscraper→urllib fallback chain for JSON API downloads. |
kintree/search/lcsc_api.py |
Makes the LCSC API test less sensitive to changing description strings. |
poetry.lock |
Lockfile regenerated; includes notable dependency source changes (e.g., digikey-api via Git). |
.gitignore |
Ignores the whole .vscode folder and a Copilot instructions file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixed the scraping of Cloudflare-protected sites. I have only tested this with LCSC (#291
) and Digikey, but I expect it to fix the Cloudflare blocking of other platforms that where failing before?
Also, the LCSC mappings have changed. I have changed it to only look at the keys of values that don't change as often, to improve long-term stability.