Python 下载网页的几种方法
总结下,Python 下载网页的几种方法
1
fd = urllib2.urlopen(url_link)
data = fd.read()
这是最简洁的一种,当然也是Get的方法
2
通过GET的方法
def GetHtmlSource(url):
try:
htmSource = ''
req = urllib2.Request(url)
fd = urllib2.urlopen(req,"")
while 1:
data = fd.read(1024)
if not len(data):
break
htmSource += data
fd.close()
del fd
del req
htmSource = htmSource.decode('cp936')
htmSource = formatStr(htmSource)
return htmSource
except socket.error, err:
str_err = "%s" % err
return ""
3
通过GET的方法
def GetHtmlSource_Get(htmurl):
htmSource = ""
try:
 
相关文档:
Python http://www.python.org/download/ wxPython http://www.wxpython.org/download.php#binaries Vpython http://vpython.org/contents/download_windows.html Matplotlib http://sourceforge.net/projects/matplotlib/files/matplotlib/ PyGlet http://www.pyglet.org/download.html PyGame http://www.pyga ......
转自:
http://hi.baidu.com/feng2211/blog/item/8b86b6d9816a3f2710df9b79.html
和
http://i.19830102.com/archives/164
Python 版本:2.6
下载地址:http://www.python.org/download/releases/2.6.1/
下载msi文件并安装
MySQLdb版本: MySQL-python-1.2.2.win32-py2.6.exe
下载地址:http://home.netimperia.com/ ......
转帖:
http://blog.csdn.net/wyingquan/archive/2008/12/20/3561094.aspx
用python自带的binascii模块计算字符串的校验码,出来的是负值,与用c写的程序得出的校验码不一样,所以就研究了一下。发现别人用的python3.0版本binascii模块计算出的crc32校验码是我想要的,没办法只好自己用python实现一下crc32的算法了。发 ......
Python 的异常处理机制
Python代码
try:
raise Exception("a", "b")
except Exception,e:
print e
finally:
print "final"
('a', ......
Memcached
是danga.com(运营LiveJournal的技术团队)开发的一套分布式内存对象缓存系统,用于在动态系统中减少数据库负载,提升性能。
网上有很多讲到Memcached For Linux的安装教程,但是Memcached For Win32 and Python的就甚少,偶尔google找到一篇
比较相近的英文教程,觉得 ......