美文网首页
bash 爬虫

bash 爬虫

作者: thebeeman | 来源:发表于2017-02-23 18:29 被阅读0次

问题描述:

我想下载特定网页中包含的.pcap和.pcap.gz文件,使用bash脚本自动完成,不需要手动挨个点。

解决方案:

1. 下载网页保存

curl -O -s https://wiki.wireshark.org/SampleCaptures

2. 提取网页中的要下载的文件名称

for i in `cat SampleCaptures | grep -hoir 'target=[a-zA-Z0-9_-]*.pcap'`

文件名特征是字母、数字、-、_这几种字符组合而成,文件名叫做'target=xx.pcap'`,用正则就可以提取。

3. 组合url字符串并下载

base="https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&";for i in `cat SampleCaptures | grep -hoir 'target=[a-zA-Z0-9_-]*.pcap'`; do echo "downloading ${base}${i} ..."; curl -s -O "${base}${i}"; done

相关文章

网友评论

      本文标题:bash 爬虫

      本文链接:https://www.haomeiwen.com/subject/dcwbwttx.html