Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/fish
- # this script uses the fish shell and should dump every LCSC Part
- #pretty much untested...
- set cats 308 312 316 319 320 328 348 365 380 385 395 423 440 450 460 470 487 493 500 513 515 570 575 582 601 905 938 953 986 10991 11032
- #as far as I can tell, both are needed. Copy from (anonymous) lcsc visit
- set X_CSRF_TOKEN "X-CSRF-Token: ..."
- set Cookie 'Cookie: ...'
- function dump
- set c $argv[1] #category
- set p $argv[2] #page
- curl 'https://lcsc.com/api/products/search' \
- -H $X_CSRF_TOKEN \
- -H $Cookie \
- --data-raw "current_page=$p&category=$c&in_stock=false&is_RoHS=false&show_icon=false&search_content=" \
- > $c-$p.json
- end
- for c in $cats;
- dump $c 1
- #set total (jq ".result.total" $c-1.json)
- set total (sed -e "s/.*total\"://;s/,.*//" $c-1.json)
- #set pages (math "ceil($total/25)")
- set pages (sed -e "s/.*total_page\"://;s/,.*//" $c-1.json)
- echo "$total in category $c, pages $pages"
- sleep 60 # one wasted minute to get the total count...
- for p in (seq 0 (math "$pages/30"))
- for i in (seq (math "$p*30+1") (math "($p+1)*30")) ## will issue more requests then needed
- echo dump $c $i
- end
- sleep 60
- end
- end
Add Comment
Please, Sign In to add comment