Python3 urllib 带https请求尝试

import urllib.request
r = urllib.request.Request("https://www.google.com")
handler = urllib.request.HTTPSHandler()
handler.https_open(r)

but this leads to AttributeError: 'Request' object has no attribute 'timeout'

How can I get HTTPSHandler.https_open() to work? Or does urlopen call the https_open function if I used

opener = urllib.request.build_opener(urllib.request.HTTPSHandler)
urllib.request.install_opener(opener)

before and actually does make a HTTPS POST request already? Thanks!

猜你喜欢

转载自blog.csdn.net/douyunqian668/article/details/83659148