Verifying HTTPS certificates with urllib.request

后端 未结 6 770
不知归路
不知归路 2021-01-18 00:07

I am trying to open an https URL using the urlopen method in Python 3\'s urllib.request module. It seems to work fine, but the documentation warns that \"[i]f neither

6条回答
  •  星月不相逢
    2021-01-18 00:14

    Works in python 2.7 and above

    context = ssl.create_default_context(cafile=certifi.where())
    req = urllib2.urlopen(urllib2.Request(url, body, headers), context=context)
    

提交回复
热议问题