简体   繁体   中英

How to export Slack messages to Python

我一直在尝试在 Slack 中使用传出 webhook 将消息从通道导出到我的 Python 程序,但我找不到这样做的方法,所以我想知道是否存在这样的事情?

Slack seems to have an API you can use to retreive the messages of a given channel. Follow this link : https://api.slack.com/messaging/retrieving

You can make a GET request to retreive the full history of the given conversation (so all the messages) :

GET https://slack.com/api/conversations.history?token=YOUR_TOKEN_HERE&channel=CONVERSATION_ID_HERE
Content-type: application/json

You can easily make GET requests wiht python using the library called 'requests'. If you're able to have a valid API token and the ID of the conversation, you will then be able to get all the messages of the chosen conversation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM