第二种方法这样写为什么不对?
request=request.Request(url)
request.add_header('user-agent','Mozilla/5.0')
response2=urllib.request.urlopen(request)
print(response2.getcode())
print(len(response2.read()))
NameError: name 'request' is not defined
用的Python3
request=request.Request(url)
request.add_header('user-agent','Mozilla/5.0')
response2=urllib.request.urlopen(request)
print(response2.getcode())
print(len(response2.read()))
NameError: name 'request' is not defined
用的Python3
2017-08-14
举报