gpt4 book ai didi

python - grequests 忽略 ssl 错误

转载 作者:行者123 更新时间:2023-12-03 02:01:10 25 4
gpt4 key购买 nike

我想传递一个参数来忽略一大组 GET 的 SSL 错误。在 requests 包中,您可以传递 verfiy=false 参数。我没有看到任何类似的请求。如果有更好的方案或方向,我很乐意。


urls = [
'https://www.heroku.com',
'https://tablib.org',
'https://httpbin.org',
'https://python-requests.org',
'https://kennethreitz.com'
]

rs = (grequests.get(u) for u in urls)

grequests.map(rs)

最佳答案

#to raise exception
def exception_handler(request, exception):
return f"Request failed: {exception}"

# to fully skip error/warning
#def exception_handler(request, exception):
# pass or do something

urls = [
'https://www.heroku.com',
'https://tablib.org',
'https://httpbin.org',
'https://python-requests.org',
'https://kennethreitz.com'
]

rs = (grequests.get(u) for u in urls)

grequests.map(rs, exception_handler=exception_handler)

#also you can do a trick with requests library (ignore certificates issue):
>>> def exception_handler(request, exception):
... return dir(request)
...
>>> rs = (grequests.get(u) for u in url)
>>> grequests.map(rs, exception_handler=exception_handler)
[['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__',
'__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', 'exception', 'kwargs',
'method', 'response', 'send', 'session', 'traceback', 'url'],
<Response[200]>]
# we can take request.url and put it in requests.get(request.url,
# verify=False)

关于python - grequests 忽略 ssl 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58940986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com