Linux命令行中采集指定頁面的圖片地址及圖片下載
發(fā)布日期:2022-02-09 08:36 | 文章來源:源碼之家
獲取指定頁面中的圖片地址: curl news.baidu.com | grep -Eio '(http|ftp|https)://[A-Za-z0-9_./]+(.jpg|.png|.gif)'
復(fù)制代碼
代碼如下:<a >http://news.baidu.com/iphone/img/loading_3.gif</a>
<a >http://h.hiphotos.baidu.com/news/pic/item/5d6034a85edf8db1cab9d24a0b23dd54564e740c.jpg</a>
<a >http://a.hiphotos.baidu.com/news/pic/item/a2cc7cd98d1001e9e447bd21ba0e7bec54e797a1.jpg</a>
<a >http://b.hiphotos.baidu.com/news/pic/item/2f738bd4b31c8701d4b01bc8257f9e2f0708ff9e.jpg</a>
<a >http://g.hiphotos.baidu.com/news/pic/item/2e2eb9389b504fc23d951e2be7dde71191ef6dd2.jpg</a>
......
<a >http://news.baidu.com/resource/img/tuiguang/news_ad_header_ipad.png</a>
<a >http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png</a>
<a >http://news.baidu.com/resource/img/tuiguang/news_home_ad_dialog_ipad_news.png</a>
grep –E 使用正則表達式
grep –i 不區(qū)分大小寫
grep –o 只顯示匹配的字符串
下載指定頁面的圖片文件:
復(fù)制代碼
代碼如下:curl -s news.baidu.com | grep -Eoi '(http|https|ftp)://[a-z0-9./_]*(jpg|png|gif)' | sort | uniq > url.txt && wget -q -nc -i url.txt
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章