获取指定页面中的图片地址: 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 | uniq > url.txt wget -q -nc -i url.txt