shell批量抓取百度首页真实网址
1、以关键词:seo为诸召例
# curl -s "http://www.baidu.com/s?ie=UTF-8&wd=seo"|grep -o -E "\"url\":\"http://www.baidu.com/link\?url=[a-z0-9A-Z_-]+\""|awk -F "\"" '{print $4}'
取得自己所需要的url
2、测试一条,是否能抓取真实网址
# curl -I -L -s http://www.baidu.com/link?url=8il2aAP_H9tDzpZMOPccNTiHoyw00yujefXkmQM2Gdy|grep Location|sed 讨侵 's/Location://'
结果显示是可侨蕉趣行的。
1、将需要抓取的关键词,存入txt文档,一行一个,utf-8格式
列:1.txt
2、批量采集
# cat 1.txt|while read line;do echo $line;curl -s "http://www.baidu.com/s?ie=UTF-8&wd="$line|grep -o -E "\"url\":\"http://www.baidu.com/link\?url=[a-z0-9A-Z_-]+\""|awk -F "\"" '{print $4}' > 2.txt;cat 2.txt|while read line;do curl -I -L -s $line|grep Location|sed 's/Location://';done;done
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:97
阅读量:123
阅读量:156
阅读量:163
阅读量:166