标题: [网络连接] [已解决]请教批处理递增问题下载多个网页文件? [打印本页]
作者: DDDYJQ1 时间: 2023-3-12 20:03 标题: [已解决]请教批处理递增问题下载多个网页文件?
有一个文件文件放网页地址
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_008
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_009
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_018
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_019
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_031
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_032
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_043
用这个可以批量下载- @echo off
- REM 设置curl.exe路径
- set curl="C:\CURL\bin\curl.exe"
- REM 设置下载html的保存目录路径
- set dstdir="E:\37\"
- REM 设置urls文件路径
- set urlfile="%~dp0TEXT103.txt"
- set tmpfile="%temp%\~%random%"
- pushd %dstdir%
- >%tmpfile% (
- echo --remote-name-all
- echo --location
- echo --compressed
- echo --user-agent "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3"
- for /f "usebackq delims=" %%A in (%urlfile%) do (
- echo --url %%A
- )
-
- )
-
- %curl% --config %tmpfile%
-
- pause
- del %tmpfile%
- popd
- pause
- exit /b
复制代码
但是只看到一个文件,如何处理?最好能以网址最后九个字符如a0001_043作为文件名,下载一个网页延时2滗,要如何改进一下?
先谢了!
作者: 77七 时间: 2023-3-12 21:20
本帖最后由 77七 于 2023-3-12 21:22 编辑
- @echo off
- REM 设置curl.exe路径
- set curl="C:\CURL\bin\curl.exe"
- set Browser="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3"
- cd /d "E:\37\"
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('type "%~dp0TEXT103.txt"') do (
- set "fileName=%%a"
- set "fileName=!fileName:~-9!"
- %curl% -A %Browser% -o "!fileName!.html" -L --location -E --compressed "%%a"
- timeout 2
- )
- endlocal
- pause
复制代码
刚学的curl命令,一些参数不知道什么意思,但是运行还是可以的
作者: DDDYJQ1 时间: 2023-3-12 21:26
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (58) schannel: Failed to get certificate location or file for --compressed
等待 0 秒,按一个键继续 ...
Warning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (58) schannel: Failed to get certificate location or file for --compressed
等待 0 秒,按一个键继续 ...
Warning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (58) schannel: Failed to get certificate location or file for --compressed
等待 0 秒,按一个键继续 ...
Warning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (58) schannel: Failed to get certificate location or file for --compressed
等待 0 秒,按一个键继续 ...
Warning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
先谢谢你,出现以上提示,没看到下载的东西
作者: 77七 时间: 2023-3-12 21:30
回复 3# DDDYJQ1
-L --location -E --compressed 把这个删掉试试
作者: DDDYJQ1 时间: 2023-3-12 21:32
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_008
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_009
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_018
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_019
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_031
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_032
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_043
https://cnkgraph.com/Category/%E ... lumnId=KR7a0001_044
作者: DDDYJQ1 时间: 2023-3-12 21:33
arning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (58) schannel: Failed to get certificate location or file for --compressed
等待 0 秒,按一个键继续 ...
Warning: The file name argument '--compressed' looks like a flag.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
作者: DDDYJQ1 时间: 2023-3-12 21:33
还是一样的
作者: DDDYJQ1 时间: 2023-3-12 21:36
可以了,谢谢,太好用了,少删除的一个
作者: 77七 时间: 2023-3-12 21:39
本帖最后由 77七 于 2023-3-12 21:42 编辑
回复 8# DDDYJQ1
应该是curl的版本问题,我用2楼的代码是正常的,刚才 本站第三方下载的 curl64 试了下,必须去掉
-L --location -E --compressed 这个参数才能下载或者我写错了,误打误撞...
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |