所以我有一个小的 bash 脚本:
for store in {4..80}
do
for page in {1..200}
do
curl 'https://website.com/shop.php?store_id='$store'&page='$page'&PHPSESSID=sessionID' -O
done
done
该脚本可以运行,但会依次下载 4-80 个商店的所有 200 个商店页面,这需要花费大量时间。 (注意 curl URL 中的 bash 变量存储和页面)
我的目标是为每个商店/页面同时运行尽可能多的 curl 请求,而不是一个接一个地运行,以节省时间。
这可能吗?
最佳答案
curl
可以自己运行循环。这将 curl
限制为 100 个同时 session :
curl 'https://website.com/shop.php?store_id=[4-80]&page=[1-200]&PHPSESSID=sessionID' -O --parallel --parallel-max 100
关于linux - 使用 Curl 在 URL 中使用变量同时下载多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69816743/