獲取指定頁(yè)面中的圖片地址: curl news.baidu.com | grep -Eio '(http|ftp|https)://[A-Za-z0-9_./]+(.jpg|.png|.gif)'
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 使用正則表達(dá)式
grep –i 不區(qū)分大小寫(xiě)
grep –o 只顯示匹配的字符串
下載指定頁(yè)面的圖片文件:
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