我知道如何使用urllib2保存页面源代码
import urllib2
page = urllib2.urlopen('http://example.com')
page_source = page.read()
with open('page_source.html', 'w') as fid:
fid.write(page_source)
但是如何使用urllib3保存源代码? PoolManager?
答案 0 :(得分:0)
使用 .data ,如下所示:
import urllib3
http = urllib3.PoolManager()
r = http.request('get', 'http://www.google.com')
with open('page_source.html', 'w') as fid:
fid.write(r.data)