检测百度关键字网站排名的python 程序
2013-01-26 10:23
519 查看
#!/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 "关键字" 我的域名部分
:
python bd.py "123" "123.net"
# -*- 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 "关键字" 我的域名部分
:
python bd.py "123" "123.net"
相关文章推荐
- phpsir 开发 一个检测百度关键字网站排名的python 程序
- phpsir 开发 一个检测百度关键字网站排名的python 程序
- Python实现的检测网站挂马程序
- 用Python和MD5实现网站挂马检测程序
- 检测网站挂马程序(Python)
- 用Python和MD5实现网站挂马检测程序
- Python实现的检测网站挂马程序
- 检测网站挂马程序(Python)
- 检测电话号码的python程序(一)
- Python检测网站链接是否已存在
- python定时检查启动某个exe程序适合检测exe是否挂了
- Linux 检测Python程序是否存在并自动重启
- 检测Python程序执行效率及内存和CPU使用的7种方法
- Python脚本检测网站链接是否存在
- python Django 检测网站访问是否正常 并邮件提醒
- 基于Python的人脸检测及识别小程序(四)
- python opencv入门 程序性能检测(8)
- python写的command下运行的友情链接检测小程序
- 检测Python程序运行时间和内存占用的方法