小编pau*_*uts的帖子

如何处理GRequests中的错误?

我有这个代码

#!/usr/bin/python

import grequests

urls = [
'http://google.com',
'http://doesnotexists.tld'
]


def do_something(response, **kwargs):
        print response.text

async_list = []

for u in urls:
    action_item = grequests.get(u, timeout=10, hooks = {'response' : do_something})
    async_list.append(action_item)

grequests.map(async_list,size=10)
Run Code Online (Sandbox Code Playgroud)

如何在不获取常见Python错误消息的情况下处理错误?
例如,对于不存在的域,它打印出"未找到".

python python-requests grequests

3
推荐指数
1
解决办法
2968
查看次数

标签 统计

grequests ×1

python ×1

python-requests ×1