HTTPSConnectionPool(host=‘qyapi.weixin.qq.com’, port=443): Max retries exceeded with url: /cgi-bin/webhook/send?key=287247b7-7fb8-4a7a-b987-215b898a201b (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7f8ad4d0a9b0>: Failed to establish a new connection: [Errno -2] Name or service not known’))
使用while和try catch 处理
当请求成功时,直接出结果,如果失败,那就一直重试,直到成功为止
while True:
try:
response = requests.post(rbt_key, headers=headers, json=data)
print(response.json())
return response.json()
except Exception as e:
print(e)
time.sleep(5)