shell批量抓取百度首页真实网址

时间:2026-02-15 15:20:44

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

shell批量抓取百度首页真实网址

2、测试一条,是否能抓取真实网址

# curl -I -L -s http://www.baidu.com/link?url=8il2aAP_H9tDzpZMOPccNTiHoyw00yujefXkmQM2Gdy|grep Location|sed  's/Location://'

结果显示是可行的。

shell批量抓取百度首页真实网址

1、将需要抓取的关键词,存入txt文档,一行一个,utf-8格式

列:1.txt

shell批量抓取百度首页真实网址

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

shell批量抓取百度首页真实网址

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com