Skip to main content

A Python interface to PKU Hole!

Project description

TreeHole

A simple Python interface to PKU Tree Hole

GitHub - License Git - Last Doc Commit

PyPI - Version PyPI - Downloads per month

Pytest - Result Git - Last Commit

目前正在持续开发完善中,欢迎使用和提出建议!

亮点

  • 简单易用
  • 文档齐全
  • token 登陆
  • 支持异步请求
  • 自动处理图像 url
  • 所有树洞数据模型均已封装为数据类
  • 涵盖(几乎?)所有暴露给用户的业务逻辑

安装

已发布至 Pypi 源,可直接使用 pip 安装:

pip3 install TreeHole

使用

from treehole import TreeHoleClient

client = TreeHoleClient(<Your Token>)
# 获取单个树洞
hole, timestamp = client.get_hole(<Hole ID>)
# 获取树洞评论
comments, attention = client.get_comment(<Hole ID>)
# 获取首页树洞列表
holes, timestamp = client.get_holes(<Page Num>)
# 获取关注树洞列表
holes, timestamp = client.get_attention(<Page Num>)
# 切换关注状态
success, attention = client.post_toggle_attention(<Hole ID>)
# 发布树洞
pid = client.post_hole(<Text>, <Image File>)
# 发布评论
pid = client.post_comment(<Hole ID>, <Text>, <Reply To>)
# 举报树洞 (!!!!!! 请勿轻易尝试)
success = client.post_report(<Hole ID>)

用例请参考 example

开发

克隆此仓库:

git clone git@github.com:TeddyHuang-00/pyTreeHole.git

编辑模式下:

pip3 install -e ".[test]"

欢迎提 issues 与 PR!

Roadmap

  • 树洞数据模型
  • 客户端封装
  • 获取单个树洞
  • 获取首页树洞
  • 获取关注树洞
  • 获取树洞回复
  • 关注/取关树洞
  • 回复树洞
  • 发布树洞
  • 举报树洞
  • 支持异步处理
  • 更多功能待补充 ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TreeHole-1.1.0.post1.tar.gz (11.7 kB view hashes)

Uploaded Source

Built Distribution

TreeHole-1.1.0.post1-py3-none-any.whl (11.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page