python练习程序(下载网页)

import os,sys, urllib2

req=urllib2.Request(sys.argv[1])
fd=urllib2.urlopen(req)

file=open('123.html','w')

while 1:
    data=fd.read(1024)
    if not len(data):
        break
    #sys.stdout.write(data)
    file.write(data)
file.close()

转载于:https://www.cnblogs.com/tiandsp/archive/2012/06/13/2547969.html

你可能感兴趣的:(python练习程序(下载网页))