import urllib
def hook(a,b,c): #回调函数
tem = 100.0 * a * b / c
if tem>100:
tem
=100
print '%.2f%%' % tem
url
= "http://192.168.102.42/www/"
path
= "d:\\1.txt"
urllib.urlretrieve(url, path, hook)
# 下载html

f = urllib.urlopen("xxx")
print f.read() # 类似于文件操作 readlines, readline



 posted on 2011-06-21 20:05  eth0  阅读(152)  评论(0编辑  收藏  举报