基于微博H5 API开发的机器人框架
Project description
WeiboBot 是一个基于微博H5 API开发的爬虫框架,提供了简单的接口,包括了一些指令,比如:转评赞,回复消息等 可以选择直接获取数据,也可以持续运行
安装
pip install WeiboBot
开始使用(生命周期)
from pathlib import Path
from WeiboBot import Bot, ChatDetail, Comment, Weibo
from loguru import logger
myBot = Bot()
@myBot.onNewMsg() # 被私信的时候触发
async def on_msg(chat: ChatDetail):
for msg in chat.msgs: # 消息列表
logger.info(f"{msg.sender_screen_name}:{msg.text}")
@myBot.onNewWeibo() # 首页刷到新微博时触发
async def on_weibo(weibo: Weibo):
logger.info(f"{weibo.text}")
@myBot.onMentionCmt() # 提及我的评论时触发
async def on_mention_cmt(cmt: Comment):
logger.info(f"收到{cmt.mid}的评论")
@myBot.onTick() # 每次循环触发
async def on_tick():
logger.info("tick")
if __name__ == "__main__":
myBot.run()
开始使用(仅调用)
import asyncio
import WeiboBot.const as const
from WeiboBot import NetTool
from loguru import logger
async def main():
async with NetTool() as nettool:
user = await nettool.user_info(nettool.mid)
logger.info(user)
weibo_example1 = await nettool.weibo_info(123456) # 获取微博
weibo_example2 = await nettool.post_weibo(
"发一条微博", visible=const.VISIBLE.ONLY_ME
)
# ...... 其他操作
if __name__ == "__main__":
asyncio.run(main())
更新路线图
目前项目仍在重构中
- 对旧API的整合
- 扩展更加多的API
- 提升登录的健壮性
- 增加更多测试用例和自动化
- 去掉 logger
示例
正在重构中
一个转发小姐姐的Bot
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
weibobot-1.0.0.tar.gz
(26.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
weibobot-1.0.0-py3-none-any.whl
(31.2 kB
view details)
File details
Details for the file weibobot-1.0.0.tar.gz.
File metadata
- Download URL: weibobot-1.0.0.tar.gz
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc3865cba64e54476c5fd05a3518f9af370caaedeb570bc3a950fc93206c749a
|
|
| MD5 |
8a9d742dd18bf259478cc572d016882c
|
|
| BLAKE2b-256 |
b7fd710cedfce2ee7f5e6512a5b3825f4582fe895c5ffde6cd7eacd59831829d
|
File details
Details for the file weibobot-1.0.0-py3-none-any.whl.
File metadata
- Download URL: weibobot-1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27173c193e935ae40fd5d9140543811e0530122dd6fd81306da469d54bc5fc85
|
|
| MD5 |
069c1d28b60132ab7d1afb92c1092699
|
|
| BLAKE2b-256 |
e8f65f0b41745a0dd3aa85ca7d63404239a5bbf44db403457e7f75b484432ea8
|