linux - 使用 Curl 在 URL 中使用变量同时下载多个文件

标签 linux bash web curl

所以我有一个小的 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/

相关文章:

bash - 如何使用 sudo、EOF 和静默输出将 cat 或 tee 放入文件

c# - 我如何在 C# 中显示来自 url 内容的小图像

macos - 将文件传输到 Web 服务器时转换 Unicode 分解

php - 如何使 file_get_contents session 感知?

linux - 如何使用 linux cli 忽略 csv 文件中的任何特定列数据?

c++ - 如何在linux上制作透明窗口

linux - 如何创建自定义 Ubuntu 镜像

linux - 如何在 Linux 终端中显示 GUI 应用程序的窗口标题

apache - 在带有引号和转义字符的 Alias 中使用 sed

bash - 打印两个模式之间的所有行,独占的,仅限第一个实例(在 sed、AWK 或 Perl 中)