为什么我使用read()出来的结果不正确
打印网页内容不正确,第一种出来 b' ',第二种不显示,请教一下怎么处理。使用的Python3
代码为:
url = () response1 = request.urlopen(url) (response1.getcode()) ((response1.read())) ((response1.read())) () req = request.Request(url) req.add_header() response2 = request.urlopen(req) (response2.getcode()) ((response2.read())) (response2.read().decode()) () cj = cookiejar.CookieJar() opener = request.build_opener(request.HTTPCookieProcessor(cj)) request.install_opener(opener) response3 = request.urlopen(url) (response3.getcode()) ((response3.read())) (cj) (response3.read().decode())
结果如图: