Linux命令行中采集指定页面的图片地址及图片下载
番茄系统家园 · 2023-01-14 01:42:59
获取指定页面中的图片地址: curl news.baidu.com | grep -Eio '(http|ftp|https)://[A-Za-z0-9_./]+(.jpg|.png|.gif)'
复制代码代码如下:
a href="http://news.baidu.com/iphone/img/loading_3.gif"http://news.baidu.com/iphone/img/loading_3.gif/a
a href="http://h.hiphotos.baidu.com/news/pic/item/5d6034a85edf8db1cab9d24a0b23dd54564e740c.jpg"http://h.hiphotos.baidu.com/news/pic/item/5d6034a85edf8db1cab9d24a0b23dd54564e740c.jpg/a
a href="http://a.hiphotos.baidu.com/news/pic/item/a2cc7cd98d1001e9e447bd21ba0e7bec54e797a1.jpg"http://a.hiphotos.baidu.com/news/pic/item/a2cc7cd98d1001e9e447bd21ba0e7bec54e797a1.jpg/a
a href="http://b.hiphotos.baidu.com/news/pic/item/2f738bd4b31c8701d4b01bc8257f9e2f0708ff9e.jpg"http://b.hiphotos.baidu.com/news/pic/item/2f738bd4b31c8701d4b01bc8257f9e2f0708ff9e.jpg/a
a href="http://g.hiphotos.baidu.com/news/pic/item/2e2eb9389b504fc23d951e2be7dde71191ef6dd2.jpg"http://g.hiphotos.baidu.com/news/pic/item/2e2eb9389b504fc23d951e2be7dde71191ef6dd2.jpg/a
......
a href="http://news.baidu.com/resource/img/tuiguang/news_ad_header_ipad.png"http://news.baidu.com/resource/img/tuiguang/news_ad_header_ipad.png/a
a href="http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png"http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png/a
a href="http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png"http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png/a
grep –E 使用正则表达式
grep –i 不区分大小写
grep –o 只显示匹配的字符串
下载指定页面的图片文件:
复制代码代码如下:
curl -s news.baidu.com | grep -Eoi '(http|https|ftp)://[a-z0-9./_]*(jpg|png|gif)'| sort | uniqurl.txtwget -q -nc -i url.txt
>&&
免责声明: 凡标注转载/编译字样内容并非本站原创,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如果你觉得本文好,欢迎推荐给朋友阅读;本文链接: https://m.nndssk.com/xtwt/187744NAJqdx.html。
