Bash 并行爬虫

xiaoxiao2021-02-28  81

Bash 并行下载脚本。1900 页,分 190 次下载完。

for i in {0..190} ; do { let start=$i*10 let end=$i*10+10 for ((page=$start;page<$end;page++)) do { echo "down $page" curl "http://www.site.org/advice/index.asp?DjjIntPcnt=$page" -o src/$page.txt } & done wait echo "finish batch $i" sleep 1 } done

如果遇到字符集问题,可下载完成后转换:

find *.txt -exec sh -c "iconv -f GB18030 -t UTF8 {} > result/{}" \;
转载请注明原文地址: https://www.6miu.com/read-79954.html

最新回复(0)