第二种办法出现错误 无法解决
print len(response2.read())
print '第二种方式' request = urllib2.urlopen(url) request.add_header("user-agent","Mozilla/5.0") response2 = urllib2.urlopen(request) print response2.getcode() print len(response2.read())
出现错误
Traceback (most recent call last):
File "E:/������ϰ/20160524/demo.py", line 14, in <module>
request.add_header("user-agent","Mozilla/5.0")
AttributeError: addinfourl instance has no attribute 'add_header'