All Projects → 7sDream → Zhihu Oauth

7sDream / Zhihu Oauth

Licence: mit
尝试解析出知乎官方未开放的 OAuth2 接口,并提供优雅的使用方式,作为 zhihu-py3 项目的替代者,目前还在实验阶段

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Zhihu Oauth

Fredr
An R client for the Federal Reserve Economic Data (FRED) API
Stars: ✭ 61 (-95.07%)
Mutual labels:  api, data, client
Flickr Sdk
Almost certainly the best Flickr API client in the world for node and the browser
Stars: ✭ 104 (-91.59%)
Mutual labels:  api, oauth, client
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (-93.69%)
Mutual labels:  api, oauth
Dsc Mercado Livre
Biblioteca de integração com o Mercado Livre
Stars: ✭ 55 (-95.55%)
Mutual labels:  api, client
Hydrogen
🎈 Hydrogen. Voted (by me) the world's lightest static-site generator built with TypeScript ❤ It uses 🔥 lit-html inspired templating for super duper performant template generation.
Stars: ✭ 80 (-93.53%)
Mutual labels:  api, data
Twittex
Twitter client library for Elixir.
Stars: ✭ 46 (-96.28%)
Mutual labels:  oauth, client
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-96.04%)
Mutual labels:  api, data
Adrestia
APIs & SDK for interacting with Cardano.
Stars: ✭ 56 (-95.47%)
Mutual labels:  api, client
Gochimp3
🐒 Golang client for MailChimp API 3.0.
Stars: ✭ 39 (-96.85%)
Mutual labels:  api, client
Igdb
Go client for the Internet Game Database API
Stars: ✭ 65 (-94.75%)
Mutual labels:  api, client
Ohloh api
Ohloh API examples
Stars: ✭ 64 (-94.83%)
Mutual labels:  api, oauth
Dimscord
A Discord Bot & REST Library for Nim.
Stars: ✭ 67 (-94.58%)
Mutual labels:  api, client
Starling Api Web Starter Kit
Starter kit and example app for using the Starling API.
Stars: ✭ 46 (-96.28%)
Mutual labels:  api, oauth
Https
Secure HTTP client with SSL pinning for Nativescript - iOS/Android
Stars: ✭ 45 (-96.36%)
Mutual labels:  api, client
Sechub
SecHub - one central and easy way to use different security tools with one API/Client
Stars: ✭ 52 (-95.8%)
Mutual labels:  api, client
Nineapi
Unofficial python client library for *official* 9GAG API. (alpha)
Stars: ✭ 43 (-96.52%)
Mutual labels:  api, client
Rtimes
R wrapper for NYTimes API for government data - ABANDONED
Stars: ✭ 55 (-95.55%)
Mutual labels:  api, data
Amoapi
AmoCRM PHP API/oAuth Client
Stars: ✭ 33 (-97.33%)
Mutual labels:  api, oauth
Twitchcsharp
Twitch C# Wrapper for the Twitch v3 REST API
Stars: ✭ 36 (-97.09%)
Mutual labels:  api, oauth
Covid19
JSON time-series of coronavirus cases (confirmed, deaths and recovered) per country - updated daily
Stars: ✭ 1,177 (-4.85%)
Mutual labels:  api, data

Zhihu-OAuth

author ci-dev ci-master docs version py-version state license

同学们,由于知乎新的 API 验证 UA,0.0.14 之前的版本已经不可用了,请尽快升级到 0.0.14 以上版本。

简介

最近在尝试解析出知乎官方未开放的 OAuth2 接口,顺便提供优雅的使用方式,作为 zhihu-py3 项目的继任者。

恩,理论上来说会比 zhihu-py3 更加稳定,原因如下:

  • 知乎 API 相比前端 HTML 来说肯定更加稳定和规范
  • 这次的代码更加规范
  • 网络请求统一放在基类中
  • 属性解析统一放在装饰器中,各知乎类只用于声明有哪些属性可供使用
  • 统一翻页逻辑,再也不用一个地方一个逻辑了
  • 翻页时的自动重试机制(虽然不知道有没有用吧)

这一新库与 zhihu-py3 相比速度更快。有关速度对比的详细信息请点击这里

这个库是 Py2 和 Py3 通用的! 但是 Py3 的优先级比 Py2 高,也就是说,我会优先保证在 Py3 下的稳定性和正确性。毕竟在我学的时候选了 Py3,所以对 2 与 3 的差异了解不是很清楚,Py2 只能尽力而为了,

后期的计划是这样的:

  • 0.0.x 这个阶段是 alpha 期,主要做的是补齐功能的工作。基本上 TODO 里的功能都会在这个时期实现。其中 0.0.5 版本计划完成和 zhihu-py3 同样多的功能(已完成)。
  • 0.1.x 这个阶段是 beta 期,主要做完善测试,修复 bug,提升性能,改善架构之类的工作吧。以上两个阶段变化很大,有可能出现不兼容老版本的更新。使用需要注意。
  • 0.2.x 及以后就是 stable 期,只要 API 不变,基本上代码结构就不会变了,接口可能会增加但一定不会减。

由于现在使用的 CLIENT_ID 和 SECRET 的获取方法并不正当,所以请大家暂时不要大规模宣传,自己用用就好啦,Thanks。

等我什么时候觉得时机成熟(等知乎真•开放 OAuth 申请?),会去知乎专栏里宣传一波的。

最近更新

目前版本是 0.0.41,没更新的快更新一下,更新说明在这里

0.0.41 版本修复了 Feed 流的一些问题,加上了 Topic.activities 接口。

0.0.40 版本增加了 Feed 首页信息流的支持。

使用

安装

pip install -U zhihu_oauth

如果安装遇到问题,请查看文档:安装

登录

请参见文档:登录

获取基础信息

代码:

from zhihu_oauth import ZhihuClient

client = ZhihuClient()

client.load_token('token.pkl')

me = client.me()

print('name', me.name)
print('headline', me.headline)
print('description', me.description)

print('following topic count', me.following_topic_count)
print('following people count', me.following_count)
print('followers count', me.follower_count)

print('voteup count', me.voteup_count)
print('get thanks count', me.thanked_count)

print('answered question', me.answer_count)
print('question asked', me.question_count)
print('collection count', me.collection_count)
print('article count', me.articles_count)
print('following column count', me.following_column_count)

输出:

name 7sDream
headline 二次元普通居民,不入流程序员,http://0v0.link
description 关注本AI的话,会自动给你发私信的哟!
following topic count 35
following people count 101
followers count 1294
voteup count 2493
get thanks count 760
answered question 258
question asked 18
collection count 9
article count 7
following column count 11

更多功能请参见文档:使用方法

文档

完整的文档可以在这里 找到。我写的文档好吧,可详细了……有啥问题先去找文档。我写的那么累你们看都不看我好不服啊!

(貌似 ReadTheDocs 在伟大的国家访问速度有点慢,建议自备手段。)

TODO

  • [x] 保证对 Python 2 和 3 的兼容性
  • [x] 用户私信支持
  • [x] Live 支持
  • [x] Pin(分享)支持
  • [x] 搜索功能(还差电子书搜索)
  • [x] 用户首页 Feed
  • [ ] 知乎电子书
  • [ ] 获取用户消息。新关注者,新评论,关注的回答有新问题
  • [ ] Token check/refresh
  • [ ] Setting
  • [ ] 规范、完善的测试
  • [ ] article.voters 文章点赞者,貌似 OAuth2 没有这个 API
  • [ ] collection.followers 这个 API 不稳定,没法返回所有关注者

协助开发

通过代码

  1. Fork
  2. 从 dev 分支新建一个分支
  3. 编写代码,更新 Changelog 和 sphinx 文档,如果可能的话加上测试
  4. PR 到原 dev 分支

通过捐款

通过 Paypal 捐款

通过 微信 捐款

通过 支付宝 捐款

PS: 捐款后最好给我发个邮件确认和提醒我哟,需要有你在记录里的昵称,是否要显示捐款金额,还可以带一句备注

PPS:另外微信收款不会显示对方微信号,所以通过微信的同学请额外附带一个交易编号做确认用~thx

捐款记录

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].