![](/img/trans.png)
[英]requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://accounts.spotify.com/api/token
[英]requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new
我有一段簡單的聊天機器人代碼:
from chatexchange.client import Client
email = "generic_email@mail.com"
password = "**********"
se_chat = Client("meta.stackexchange.com")
se_chat.login(email, password)
def on_event(event, _):
if event.data['event_type'] == 1:
event.message.reply("Hello World!")
room = se_chat.get_room('1543')
room.join()
room.watch_socket(on_event)
while True:
pass
room.leave()
但是當我運行代碼時,我得到:
Exception in thread message_sender:
Traceback (most recent call last):
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 183, in _worker
self._do_action_despite_throttling(next_action)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 221, in _do_action_despite_throttling
response = self._br.send_message(room_id, text)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 301, in send_message
{'text': text})
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 133, in post_fkeyed
return self.post(url, data, headers)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 113, in post
return self._request('post', url, data, headers, with_chat_root)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 102, in _request
response.raise_for_status()
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new
我的代碼有什么問題?
我有一段簡單的聊天機器人代碼:
from chatexchange.client import Client
email = "generic_email@mail.com"
password = "**********"
se_chat = Client("meta.stackexchange.com")
se_chat.login(email, password)
def on_event(event, _):
if event.data['event_type'] == 1:
event.message.reply("Hello World!")
room = se_chat.get_room('1543')
room.join()
room.watch_socket(on_event)
while True:
pass
room.leave()
但是當我運行代碼時,我得到:
Exception in thread message_sender:
Traceback (most recent call last):
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 183, in _worker
self._do_action_despite_throttling(next_action)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 221, in _do_action_despite_throttling
response = self._br.send_message(room_id, text)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 301, in send_message
{'text': text})
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 133, in post_fkeyed
return self.post(url, data, headers)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 113, in post
return self._request('post', url, data, headers, with_chat_root)
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 102, in _request
response.raise_for_status()
File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new
我的代碼有什么問題?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.