python写的command下运行的友情链接检测小程序
2009-11-21 12:06
369 查看
工作中需要做SEO的工作.所以写了个友情链接检测的小程序.
python效率很高.程序中主要注意编码的问题.其他很是很简单的
# -*- coding: cp936 -*-
import urllib
def getcharset(url):
html = urllib.urlopen(url)
source = html.read()
d = source.index('charset')
d += 8
if source[d] == 'u':
source = source.decode('utf8')
target = u'...................'
add = source.find(target)
if add == -1:
print "<<<警告>>>,对方网站没有链接"
else:
print "友情链接正常"
elif source[d] == 'g':
source = source.decode('gbk')
target = u'....................'
add = source.find(target)
if add == -1:
print "<<<警告>>>,对方网站没有链接"
else:
print "友情链接正常"
if __name__ == '__main__':
getcharset("...........................")
python效率很高.程序中主要注意编码的问题.其他很是很简单的
# -*- coding: cp936 -*-
import urllib
def getcharset(url):
html = urllib.urlopen(url)
source = html.read()
d = source.index('charset')
d += 8
if source[d] == 'u':
source = source.decode('utf8')
target = u'...................'
add = source.find(target)
if add == -1:
print "<<<警告>>>,对方网站没有链接"
else:
print "友情链接正常"
elif source[d] == 'g':
source = source.decode('gbk')
target = u'....................'
add = source.find(target)
if add == -1:
print "<<<警告>>>,对方网站没有链接"
else:
print "友情链接正常"
if __name__ == '__main__':
getcharset("...........................")
相关文章推荐
- 转载:10种检测Python程序运行时间、CPU和内存占用的方法
- 检测Python程序运行时间和内存占用的方法
- 10种检测Python程序运行时间、CPU和内存占用的方法
- 10种检测Python程序运行时间、CPU和内存占用的方法
- Python+hadoop Streaming编写的Map-Reduce程序与调试运行
- 【python】100行代码python爬虫程序,抓取网站图片存储本地(附:中文链接解决)
- Notepad++ 运行Python程序
- 谈谈 Python 程序的运行原理
- Python--到cmd中输入'pip' 不是内部或外部命令,也不是可运行的程序或批处理文件。
- PYTHON的程序在LINUX后台运行
- Python中四种运行其他程序的方式
- 在iOS程序中检测数字和链接
- 在Code::Blocks中编辑并运行python程序
- 程序运行流程——链接、装载及执行
- C#检测同个程序被打开或运行多次
- 一个检测网页是否有日常链接的python脚本
- 程序检测自身是否运行在虚拟机下
- eclipse下添加GCC编译器的编译链接库以及程序运行参数方法
- 运行Python程序的2种方式
- Python获取程序运行目录和脚本目录