源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

phpsir 开发 一个检测百度关键字网站排名的python 程序

  • 时间:2022-01-26 13:44 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:phpsir 开发 一个检测百度关键字网站排名的python 程序
源码如下 :保存成utf-8 bd.py 文件
[u]复制代码[/u] 代码如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import urllib ,urllib2 import re def baidu(w): url= "http://www.baidu.com/s?" values = { "w":w.encode('gbk','ignore') } data = urllib.urlencode(values) newurl = url + data response = urllib2.urlopen(newurl) the_page = response.read().decode('gbk','ignore') return the_page def ana(data,mysite): o = re.compile("href=\"(.+?)\"") f = o.findall(data) line = 1 for ff in f: if not re.search("baidu",ff) and not re.search("^s\?",ff) and re.search("^http:\/\/",ff): if re.search(mysite,ff): print "* " ,line ,ff else: print line ,ff line += 1 if __name__ == "__main__": mysite = sys.argv[2] data = baidu(sys.argv[1].decode('utf-8')) ana(data,mysite)
用法 python bd.py "关键字" 我的域名部分 : 例:
[u]复制代码[/u] 代码如下:
python bd.py "vbs" "jb51.net"
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部