方式1
import urllib.requestfile = urllib.request.urlopen(‘http://www.baidu.com/‘)data = file.read()fhandle = open (‘D:\siq\part4/1.html‘,‘wb‘)fhandle.write(data)fhandle.close() 方式2
import urllib.request filename = urllib.request.urlretrieve(‘http://www.baidu.com/‘,filename=‘D:\siq\part4/2.html‘)
时间: 2024-10-18 17:02:32