【发布时间】:2022-01-15 00:37:41
【问题描述】:
我打算做一个小的网络爬虫脚本:
我有一个 shell 脚本 scrape.sh,我使用 chmod 755 使其可执行
curl 用于抓取数据(我打算抓取 30,000 个 url)
scrape.sh 的内容:
curl https://example.com/something/UID1 --output UID1.html
curl https://example.com/something/UID2 --output UID2.html
curl https://example.com/something/UID3 --output UID3.html
curl https://example.com/something/UID4 --output UID4.html
...
curl https://example.com/something/UID30000 --output UID30000.html
除了在我的 scrape.sh 中使用 30.000 行代码之外,还有什么更紧凑的方式来完成这项工作?
【问题讨论】:
-
请问您是从哪里获得这些 UID 的?它们在文件中吗?它们可以通过编程方式生成吗?
-
curl不是刮板。它只是下载网站的 html 源代码。因此,在您的 'scrape.sh' 中,您忘记包含用于提取所需信息的实际 HTML 解析器。