m-wrzr / populartimes

MIT License
815 stars 167 forks source link

Why is SSL / SSLContext / PROTOCOL_TLSv1 used? #92

Closed mick-net closed 4 years ago

mick-net commented 4 years ago

Can anybody help me out why the request to Google is using the following code?

    # noinspection PyUnresolvedReferences
    gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)

     resp = urllib.request.urlopen(urllib.request.Request(
     url=search_url, data=None, headers=USER_AGENT), context=gcontext)

Without the SSL gcontext it also works:

     resp = urllib.request.urlopen(urllib.request.Request(
     url=search_url, data=None, headers=USER_AGENT))
mick-net commented 4 years ago

Not relevant

OndroNR commented 3 years ago

Well, I am still interested in reason. It does not work on some python hostings with gcontext.