python requests
[About]
http://www.python-requests.org/en/latest/
[与urllib2比较]
http://www.oschina.net/code/snippet_782578_27510
[错误]
requests.exceptions.SSLError:[Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate veryfy failed
重现
import requests url='https://self-sign web/' #自签名HTTPS站点 requests.get(url)
解决办法1:
import requests url='https://self-sign web/' requests.get(url, verify=False) #不验证
解决办法2:
import requests url='https://self-sign web/' requests.get(url, verify='/etc/pki/tls/certs/server.crt') #指定证书
[错误2]
requests.exceptions.SSLError: hostname 'XXXXX' doesn't match u'YYYYY'
证书中主机描述与实际不符