我有这个代码
#!/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)
如何处理错误而不收到通常的 Python 错误消息?
例如,对于不存在的域,它会打印出“未找到”。