我当前正在尝试创建一个批处理脚本,以从digikey(http://www.digikey.com/product-search/download.csv?lang=en&site=ca&pv7=2&KeyWords=SZMMBZ5V6ALT1G&rohs=1&pageSize=500)下载此csv文件。如果在浏览器中手动输入URL,则会进行下载。有没有办法下载批处理脚本并将此csv保存到文件中?
我已经尝试过wget和curl,什么也没有返回。我也尝试过在python中使用硒,但是页面打开时出现403错误。
curl -o yes.csv "http://www.digikey.com/product-search/download.csv?lang=en&site=ca&pv7=2&KeyWords=SZMMBZ5V6ALT1G&rohs=1&pageSize=500"
SET AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
Wget -U %AGENT% -O yes.csv "http://www.digikey.com/product-search/download.csv?lang=en&site=ca&pv7=2&KeyWords=SZMMBZ5V6ALT1G&rohs=1&pageSize=500"
答案 0 :(得分:0)
也许vbs还可以吗?
@echo off
call:download "http://www.digikey.com/product-search/download.csv?lang=en&site=ca&pv7=2&KeyWords=SZMMBZ5V6ALT1G&rohs=1&pageSize=500" "%~dp0thing.csv"
exit
:download
(echo src = "%~1"
echo Set v1 = CreateObject ("MSXML2.XMLHTTP"^)
echo Set v2 = CreateObject ("ADODB.Stream"^)
echo v1.open "GET", src, false
echo v1.send (^)
echo v2.open
echo v2.Type = 1
echo v2.Write v1.ResponseBody
echo v2.SaveToFile "%~2") >"%~dpn0.vbs"
cscript "%~dpn0.vbs"
del "%~dpn0.vbs" >nul
goto:eof
答案 1 :(得分:0)
我最终使用start来启动页面,然后开始下载,接着是睡眠时间和移动功能,将文件放置在正确的位置。
set browser=chrome.exe
start %browser% "http://www.digikey.com/product-search/download.csv?
lang=en&site=ca&pv7=2&KeyWords=SZMMBZ5V6ALT1G&rohs=1&pageSize=500"
sleep 5
move -----------------------------------------------------