websocket._exceptions.WebSocketBadStatusException: Handshake status 429 Too Many Requests

Traceback (most recent call last):
  File "D:/spider_telegram/spider_17_deribit/spider_2_get_content.py", line 213, in <module>
    hour_spider(item)
  File "D:/spider_telegram/spider_17_deribit/spider_2_get_content.py", line 168, in hour_spider
    ws = websocket.create_connection(url=url, headers=headers)
  File "C:Python37libsite-packageswebsocket\_core.py", line 595, in create_connection
    websock.connect(url, **options)
  File "C:Python37libsite-packageswebsocket\_core.py", line 252, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "C:Python37libsite-packageswebsocket\_handshake.py", line 59, in handshake
    status, resp = _get_resp_headers(sock)
  File "C:Python37libsite-packageswebsocket\_handshake.py", line 145, in _get_resp_headers
    raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 429 Too Many Requests

查看代码,忘记关闭链接了,加上ws.close() 即可

  

            url = 'wss://test.deribit.com/ws/api/v2'
            ws = websocket.create_connection(url=url, headers=headers)
            ws.send(json.dumps(msg))
            response = ws.recv()
            # ws.close()    
如果觉得对您有帮助,麻烦您点一下推荐,谢谢!



好记忆不如烂笔头
原文地址:https://www.cnblogs.com/xuchunlin/p/14919106.html