卷曲:请求之间的睡眠/延迟

rfs*_*010 8 curl flurry

我试图使用以下命令下载乱码异常日志.

curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"
Run Code Online (Sandbox Code Playgroud)

它工作正常,它根据偏移量(10,20,30等)下载csv文件.我想在每个请求之间插入一个延迟.是否有可能在CURL中这样做?

Muh*_*rar 6

使用 bash shell (Linux) :

while :
do
    curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"
    sleep 5m
done
Run Code Online (Sandbox Code Playgroud)

这是一个无限循环,延迟由sleep命令给出。

编辑。在 Windows 机器上,您可以改为执行此技巧:

for /L %i in (0,0,0) do (
    curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"
    ping -n XX 127.0.0.1>NUL
)
Run Code Online (Sandbox Code Playgroud)

sleep命令在 Windows 上不可用。但是你可以ping用来“模仿”它。只需将上面的 XX 替换为您想要延迟的秒数。


Alb*_*tti 5

wget 有延迟选项

wget --wait=seconds
Run Code Online (Sandbox Code Playgroud)

以及随机延迟选项

wget --random-wait
Run Code Online (Sandbox Code Playgroud)