Skip to content

LCSC API Update #291

Description

@PolymorphicAgent

In v1.2.1, LCSC fetching is broken, as the download function uses 'requests' rather than 'cloudscraper', causing requests to fail.

Fix

tools.py

Replace the following lines starting at 137:

response = requests.get(url)
data_json = response.json()
return data_json

with

import cloudscraper

scraper = cloudscraper.create_scraper()

response = scraper.get(
    url,
    headers=headers,
    timeout=timeout,
 )

response.raise_for_status()

data_json = response.json()
return data_json

You can move the import to the top if you feel like it...

lcsc_api.py

This fixes the test api method

update line 137 to:

'productIntroEn': '100pF C0G ±5% 25V 0201 Ceramic Capacitors RoHS',

tested, this works

sorry for lack of formatting, I had to write this in a rush!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions