# JKit
[![许可证](https://img.shields.io/github/license/FHU-yezi/JKit?style=flat-square&label=%E8%AE%B8%E5%8F%AF%E8%AF%81)](https://github.com/FHU-yezi/JKit/blob/v3/LICENSE)
[![简书主页](https://img.shields.io/badge/%E7%AE%80%E4%B9%A6-%E5%88%9D%E5%BF%83%E4%B8%8D%E5%8F%98__%E5%8F%B6%E5%AD%90-black?style=flat-square&color=EA6F5A)](https://www.jianshu.com/u/ea36c8d8aa30)
[![PyPI 最新版](https://img.shields.io/pypi/v/jkit?style=flat-square&label=PyPI)
](https://pypi.python.org/pypi/jkit)
[![支持的 Python 版本](https://img.shields.io/pypi/pyversions/jkit.svg?style=flat-square&label=Python%20%E7%89%88%E6%9C%AC)](https://pypi.python.org/pypi/jkit)
[![Ruff](https://img.shields.io/badge/%E9%9D%99%E6%80%81%E6%A3%80%E6%9F%A5-Ruff-purple?style=flat-square)
](https://github.com/astral-sh/ruff)
[![Pyright](https://img.shields.io/badge/%E7%B1%BB%E5%9E%8B%E6%A3%80%E6%9F%A5-Pyright-blue?style=flat-square)
](https://github.com/microsoft/pyright)
[![Black](https://img.shields.io/badge/%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC-Black-black?style=flat-square)
](https://github.com/psf/black)
<p align="center">
<b>创造可能性。</b>
</p>
> [!WARNING]
> JKit v3 正在 Alpha 测试中,可能随时进行重大变更。
# 快速上手
```bash
pip install jkit --pre
```
```python
import asyncio
from jkit import User
async def main() -> None:
user = User.from_url("https://www.jianshu.com/u/622a3993108c")
info = await user.info
print(f"用户昵称:{info.name}")
print(
f"性别:{info.gender.value},会员等级:{info.membership_info.type.value}\n"
f"会员过期时间:{info.membership_info.expired_at}"
)
asyncio.run(main())
```
```
用户昵称:任真
性别:女,会员等级:白金会员
会员过期时间:2024-04-12 14:24:24
```
# 亮点
- [x] 完全异步操作
- [x] 基于 [msgspec](https://github.com/jcrist/msgspec) 的数据模型和自动校验
# 获取简书鉴权 Token
**目前仅支持电脑端操作。**
登录简书账号后,打开浏览器开发者工具(F12),选择「存储」(Storage)选项卡,找到域名 `https://www.jianshu.com` 下存储的 Cookies 列表。
获取键 `remember_user_token` 对应的值,然后初始化 `JianshuCredential` 对象,代码如下所示:
```python
from jkit.credential import JianshuCredential
credential = JianshuCredential(
token="<remember_user_token>"
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/FHU-yezi/JKit",
"name": "jkit",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "jianshu, SDK",
"author": "yezi",
"author_email": "yehaowei20060411@qq.com",
"download_url": "https://files.pythonhosted.org/packages/2e/d6/08165ef675ea797fdae8ad65df9a51a54aaeff3ba4e3809f0243e0b4e8d5/jkit-3.0.0a16.tar.gz",
"platform": null,
"description": "# JKit\n\n[![\u8bb8\u53ef\u8bc1](https://img.shields.io/github/license/FHU-yezi/JKit?style=flat-square&label=%E8%AE%B8%E5%8F%AF%E8%AF%81)](https://github.com/FHU-yezi/JKit/blob/v3/LICENSE)\n[![\u7b80\u4e66\u4e3b\u9875](https://img.shields.io/badge/%E7%AE%80%E4%B9%A6-%E5%88%9D%E5%BF%83%E4%B8%8D%E5%8F%98__%E5%8F%B6%E5%AD%90-black?style=flat-square&color=EA6F5A)](https://www.jianshu.com/u/ea36c8d8aa30)\n\n[![PyPI \u6700\u65b0\u7248](https://img.shields.io/pypi/v/jkit?style=flat-square&label=PyPI)\n](https://pypi.python.org/pypi/jkit)\n[![\u652f\u6301\u7684 Python \u7248\u672c](https://img.shields.io/pypi/pyversions/jkit.svg?style=flat-square&label=Python%20%E7%89%88%E6%9C%AC)](https://pypi.python.org/pypi/jkit)\n\n[![Ruff](https://img.shields.io/badge/%E9%9D%99%E6%80%81%E6%A3%80%E6%9F%A5-Ruff-purple?style=flat-square)\n](https://github.com/astral-sh/ruff)\n[![Pyright](https://img.shields.io/badge/%E7%B1%BB%E5%9E%8B%E6%A3%80%E6%9F%A5-Pyright-blue?style=flat-square)\n](https://github.com/microsoft/pyright)\n[![Black](https://img.shields.io/badge/%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC-Black-black?style=flat-square)\n](https://github.com/psf/black)\n\n\n<p align=\"center\">\n <b>\u521b\u9020\u53ef\u80fd\u6027\u3002</b>\n</p>\n\n> [!WARNING]\n> JKit v3 \u6b63\u5728 Alpha \u6d4b\u8bd5\u4e2d\uff0c\u53ef\u80fd\u968f\u65f6\u8fdb\u884c\u91cd\u5927\u53d8\u66f4\u3002\n\n# \u5feb\u901f\u4e0a\u624b\n\n```bash\npip install jkit --pre\n```\n\n```python\nimport asyncio\n\nfrom jkit import User\n\n\nasync def main() -> None:\n user = User.from_url(\"https://www.jianshu.com/u/622a3993108c\")\n\n info = await user.info\n print(f\"\u7528\u6237\u6635\u79f0\uff1a{info.name}\")\n print(\n f\"\u6027\u522b\uff1a{info.gender.value}\uff0c\u4f1a\u5458\u7b49\u7ea7\uff1a{info.membership_info.type.value}\\n\"\n f\"\u4f1a\u5458\u8fc7\u671f\u65f6\u95f4\uff1a{info.membership_info.expired_at}\"\n )\n\n\nasyncio.run(main())\n```\n\n```\n\u7528\u6237\u6635\u79f0\uff1a\u4efb\u771f\n\u6027\u522b\uff1a\u5973\uff0c\u4f1a\u5458\u7b49\u7ea7\uff1a\u767d\u91d1\u4f1a\u5458\n\u4f1a\u5458\u8fc7\u671f\u65f6\u95f4\uff1a2024-04-12 14:24:24\n```\n\n# \u4eae\u70b9\n\n- [x] \u5b8c\u5168\u5f02\u6b65\u64cd\u4f5c\n- [x] \u57fa\u4e8e [msgspec](https://github.com/jcrist/msgspec) \u7684\u6570\u636e\u6a21\u578b\u548c\u81ea\u52a8\u6821\u9a8c\n\n# \u83b7\u53d6\u7b80\u4e66\u9274\u6743 Token\n\n**\u76ee\u524d\u4ec5\u652f\u6301\u7535\u8111\u7aef\u64cd\u4f5c\u3002**\n\n\u767b\u5f55\u7b80\u4e66\u8d26\u53f7\u540e\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177\uff08F12\uff09\uff0c\u9009\u62e9\u300c\u5b58\u50a8\u300d\uff08Storage\uff09\u9009\u9879\u5361\uff0c\u627e\u5230\u57df\u540d `https://www.jianshu.com` \u4e0b\u5b58\u50a8\u7684 Cookies \u5217\u8868\u3002\n\n\u83b7\u53d6\u952e `remember_user_token` \u5bf9\u5e94\u7684\u503c\uff0c\u7136\u540e\u521d\u59cb\u5316 `JianshuCredential` \u5bf9\u8c61\uff0c\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a\n\n```python\nfrom jkit.credential import JianshuCredential\n\ncredential = JianshuCredential(\n token=\"<remember_user_token>\"\n)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u7b80\u4e66\u975e\u5b98\u65b9 SDK - \u521b\u9020\u53ef\u80fd\u6027",
"version": "3.0.0a16",
"project_urls": {
"Homepage": "https://github.com/FHU-yezi/JKit",
"Repository": "https://github.com/FHU-yezi/JKit"
},
"split_keywords": [
"jianshu",
" sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4d5ad12ecf14ac37d1a45bc8221bb75e4fa2b9efb860e886087c8f4d2a86742f",
"md5": "70b1e1dff5252a03f5875f7353bc2e19",
"sha256": "3ee1b6b4ffa25e56108ba28988f3612649f787fca94caf961af1f60bc6a805e3"
},
"downloads": -1,
"filename": "jkit-3.0.0a16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "70b1e1dff5252a03f5875f7353bc2e19",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 30419,
"upload_time": "2024-03-30T14:54:55",
"upload_time_iso_8601": "2024-03-30T14:54:55.955803Z",
"url": "https://files.pythonhosted.org/packages/4d/5a/d12ecf14ac37d1a45bc8221bb75e4fa2b9efb860e886087c8f4d2a86742f/jkit-3.0.0a16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2ed608165ef675ea797fdae8ad65df9a51a54aaeff3ba4e3809f0243e0b4e8d5",
"md5": "793566a6de2933846ecf82a839ed9c29",
"sha256": "76f2a5949268cc4f88d799b2b2b71a2cafdfda55521b765d4920595543cd6182"
},
"downloads": -1,
"filename": "jkit-3.0.0a16.tar.gz",
"has_sig": false,
"md5_digest": "793566a6de2933846ecf82a839ed9c29",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 20903,
"upload_time": "2024-03-30T14:54:57",
"upload_time_iso_8601": "2024-03-30T14:54:57.135153Z",
"url": "https://files.pythonhosted.org/packages/2e/d6/08165ef675ea797fdae8ad65df9a51a54aaeff3ba4e3809f0243e0b4e8d5/jkit-3.0.0a16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-30 14:54:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FHU-yezi",
"github_project": "JKit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "jkit"
}