shell批量获取百度及google收录与alexa排名

这个shell脚本查询百度收录及alexa排名没有包含google,google要多增加一个cook跟referer的资料,不然得不到页面..修改一下域名跟路径就可以用了~

  1. #!/bin/bash
  2. cd /root/get_google_baidu_site
  3. $(curl http://alexa.chinaz.com/?domain=baiqiuyi.com -o alexa.temp && cat alexa.temp |iconv -f gb2312 -t utf8|grep 综合排名|sed -e 's/<[^>]*>//g' -e 's/^[ \t]*//g' -e '2d' > today.result && rm alexa.temp)
  4. $(wget -q http://www.baidu.com/s?wd=site%3Abaiqiuyi.com -O baiqiuyi.temp)
  5. $(head -80 baiqiuyi.temp|iconv -f gb2312 -t utf8 > baiqiuyi.html && rm baiqiuyi.temp)
  6. curl -A "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.0)" -e "www.google.cn" -D google.txt "http://www.google.cn/search?hl=zh-CN&q=site%3Abaiqiuyi.com&btnG=Google+%E6%90%9C%E7%B4%A2&meta=&aq=f&oq="|sed -e 's/<[^>]*>//g' -re 's/.*(中国的网页 &nbsp;网页&nbsp;.*项符合 baiqiuyi\.com).*/\1/g;'|grep "中国的网页 &nbsp;网页&nbsp;约有"|sed -e 's/&nbsp;//g' -e 's/中国的网页 网页/baiqiuyi.com Google 一下/' -e 's/ baiqiuyi\.com//g' >> today.result
  7.    $(sed -e '/百度一下/!d' -e 's/<[^>]*>//g' -e 's/&nbsp;//g' -e '1,2d' baiqiuyi.html >> today.result|echo -e "\n\n" >>today.result && rm baiqiuyi.html)
  8. $(cat kof1.temp|iconv -f gb2312 -t utf8 > kof1.result && rm kof1.temp)
  9. $(sed -e '/百度一下/!d' -e 's/<[^>]*>//g' -e 's/&nbsp;//g' -e '1,2d' kof1.result >> today.result |echo -e "\n\n"$(date) >> today.result && rm kof1.result)
  10. clear
  11. cat /root/get_google_baidu_site/today.result && rm /root/get_google_baidu_site/today.result

得到的结果大概为这样:

  1. 网站 www.baiqiuyi.comAlexa 上综合排名第 210,313 位。
  2. baiqiuyi.com Google 一下约有 246 项符合
  3. 百度一下,找到相关网页197篇,用时0.001
  4.  
  5. Tue Apr 28 21:43:05 CST 2009

10 Comments

  1. 楼主 打扰下,问下用你这个的抓取网站alexa排名的脚本 不能输出排名数字 是怎么回事

      1. root@debian:~# curl -sl http://alexa.chinaz.com/?Domain=https://baiqiuyi.com/  |iconv -f gb2312 -t utf8|sed 's/<[^>]*>//g'|sed -n '/ 上全球综合排名第/p'
      2.         网站 www.baiqiuyi.comAlexa 上全球综合排名第 625,494 位,中文排名第 71501 位。

      这样试试,见笑了,很久前学shell弄的,其实不用这么麻烦的。

  2. 学习了。不错。

  3. 是和全备份做了同一个目录。你的要求好像不可以实现,推荐你去下载过来试试。



    回复:hi曙光,我试过了,不行的~

  4. 这样的东西是不是搞起来很累。



    回复:大哥 生计啊没办法~