-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scrape Basic Parts from JLCPCB.py
24 lines (22 loc) · 1.31 KB
/
Scrape Basic Parts from JLCPCB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!python3
import http.client
import json
import csv
conn= http.client.HTTPSConnection("jlcpcb.com")
headers = {'Content-type': 'application/x-www-form-urlencoded'}
with open('Basic Parts.csv', 'w', newline='') as csv_file:
component_writer = csv.writer(csv_file, delimiter=',')
component_writer.writerow(['Manufacturer','LCSC Part #','Description','Package','Stock','Type','MFR.Part #',
'Datasheet','Price (USD)'])
for n in range(1,8):
data=f"currentPage={n}&pageSize=100&keyword=&secondeSortName=&componentSpecification="
conn.request("POST", "/shoppingCart/smtGood/selectSmtComponentList", data , headers)
r1 = conn.getresponse()
body = r1.read()
print(r1.status)
for component in json.loads(body)['data']['list']:
if component['componentLibraryType']=='base':
component_writer.writerow([component['componentBrandEn'],component['componentCode'],component[ 'describe'],component['componentSpecificationEn']+"\t",
component['stockCount'],component['componentTypeEn'],component['componentModelEn'],component['dataManualUrl'],
component['componentPrices'][0]['productPrice']])
conn.close()