欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)保存網(wǎng)頁到本地示例

 更新時間:2014年03月16日 10:36:03   作者:  
這篇文章主要介紹了python實現(xiàn)保存網(wǎng)頁到本地示例,需要的朋友可以參考下

學(xué)習(xí)python示例:實現(xiàn)保存網(wǎng)頁到本地

復(fù)制代碼 代碼如下:

#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('http://www.dbjr.com.cn/', reporthook=reporthook)
 print
 print '文件是:', filename
 print '頭文件是'
 print msg
 print '刪除前的文件地址:', os.path.exists(filename)

finally:
 urllib.urlcleanup()

 print '文件依然存在:', os.path.exists(filename)

相關(guān)文章

最新評論