擅长:python、mysql、java
<p>要检查<a href="http://docs.python.org/library/ssl.html" rel="noreferrer">ssl support in Python 2.6+</a>:</p>
<pre><code>try:
import ssl
except ImportError:
print "error: no ssl support"
</code></pre>
<p>要通过<a href="https://stackoverflow.com/questions/1935939/python-send-cmd-on-socket/1936923#1936923">https</a>连接:</p>
<pre><code>import urllib2
try:
response = urllib2.urlopen('https://example.com')
print 'response headers: "%s"' % response.info()
except IOError, e:
if hasattr(e, 'code'): # HTTPError
print 'http error code: ', e.code
elif hasattr(e, 'reason'): # URLError
print "can't connect, reason: ", e.reason
else:
raise
</code></pre>