Merge branch 'develop' of https://github.com/hong56hk/you-get into hong56hk-develop

This commit is contained in:
Mort Yao 2022-04-19 21:12:33 +02:00
commit aef4c4ec0c
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -362,7 +362,12 @@ def getHttps(host, url, headers, debuglevel=0):
# DEPRECATED in favor of get_content()
def get_response(url, faker=False):
logging.debug('get_response: %s' % url)
ctx = None
if insecure:
# ignore ssl errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# install cookies
if cookies:
opener = request.build_opener(request.HTTPCookieProcessor(cookies))
@ -370,10 +375,10 @@ def get_response(url, faker=False):
if faker:
response = request.urlopen(
request.Request(url, headers=fake_headers), None
request.Request(url, headers=fake_headers), None, context=ctx,
)
else:
response = request.urlopen(url)
response = request.urlopen(url, context=ctx)
data = response.read()
if response.info().get('Content-Encoding') == 'gzip':