Posted in Python onMarch 16, 2014
学习python示例:实现保存网页到本地
#coding=utf-8 __auther__ = 'xianbao' import urllib import os def reporthook(blocks_read, block_size, total_size): if not blocks_read: print '打开连接' return if total_size < 0: print "%d正在读取(%dbytes完成)"%(blocks_read, blocks_read * block_size) else: amout_read = block_size * blocks_read print '%d正在读取,%d/%d'%(blocks_read, amout_read, total_size) return try: filename, msg = urllib.urlretrieve('https://3water.com/', reporthook=reporthook) print print '文件是:', filename print '头文件是' print msg print '删除前的文件地址:', os.path.exists(filename) finally: urllib.urlcleanup() print '文件依然存在:', os.path.exists(filename)
python实现保存网页到本地示例
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@