mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
Merge branch 'develop' of https://github.com/hong56hk/you-get into hong56hk-develop
This commit is contained in:
commit
aef4c4ec0c
@ -362,7 +362,12 @@ def getHttps(host, url, headers, debuglevel=0):
|
|||||||
# DEPRECATED in favor of get_content()
|
# DEPRECATED in favor of get_content()
|
||||||
def get_response(url, faker=False):
|
def get_response(url, faker=False):
|
||||||
logging.debug('get_response: %s' % url)
|
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
|
# install cookies
|
||||||
if cookies:
|
if cookies:
|
||||||
opener = request.build_opener(request.HTTPCookieProcessor(cookies))
|
opener = request.build_opener(request.HTTPCookieProcessor(cookies))
|
||||||
@ -370,10 +375,10 @@ def get_response(url, faker=False):
|
|||||||
|
|
||||||
if faker:
|
if faker:
|
||||||
response = request.urlopen(
|
response = request.urlopen(
|
||||||
request.Request(url, headers=fake_headers), None
|
request.Request(url, headers=fake_headers), None, context=ctx,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
response = request.urlopen(url)
|
response = request.urlopen(url, context=ctx)
|
||||||
|
|
||||||
data = response.read()
|
data = response.read()
|
||||||
if response.info().get('Content-Encoding') == 'gzip':
|
if response.info().get('Content-Encoding') == 'gzip':
|
||||||
|
Loading…
Reference in New Issue
Block a user