当前位置: 首页 > news >正文

Wiz笔记二次开发

目前wiz笔记的docker版本停留在1.0.31版本,想要使用最新的功能就不能使用docker自建的服务端了,于是打算在现有基础上根据webAPI的内容对其进行二次开发
目前解析出来的接口都是我急需使用的,大家可以参考,我会在未来慢慢开发完善的

import requests,re
from bs4 import BeautifulSoup
class wiz:def __init__(self,username,password,domain):self.username = usernameself.password = passwordself.token = ""self.kbGuid = ''self.headers = {}self.data = []self.domain = domainself.update_url()  # 初始化 URLdef update_url(self):self.url={"getWizToken":f"{self.domain}/as/user/login","getFolder":f"{self.domain}/ks/category/all/{self.kbGuid}","logOut":f"{self.domain}/as/user/logout","getMessageList":f"{self.domain}/ks/note/list/category/{self.kbGuid}","getMessage":f"{self.domain}/ks/note/download/{self.kbGuid}/",}def getWizToken(self):params = {'clientType': 'web','clientVersion': '4.0','lang': 'zh-cn',}json_data = {'userId': self.username,'password': self.password,'autoLogin': True,'domain': 'clouded.top','deviceId': None,}response = requests.post(self.url['getWizToken'],params=params,json=json_data,).json()if response['returnCode'] == 200:#登陆成功self.token = response["result"]["token"]self.kbGuid = response["result"]["kbGuid"]self.update_url()self.headers["X-Wiz-Token"] = self.tokenelif response['returnCode'] == 31002:#用户名密码错误print(response["returnMessage"])def getFolder(self):response = requests.get(self.url['getFolder'],headers=self.headers).json()for item in response['result']:# print(item)self.getMessageList(item)def logOut(self):params = {'domain': 'clouded.top','clientType': 'web','clientVersion': '4.0','lang': 'zh-cn',}requests.get(self.url['logOut'], params=params,headers=self.headers)def getMessageList(self,path):params = {'lang': 'zh-cn','category': path,'start': '0','count': '100','orderBy': 'modified','ascending': 'desc','withAbstract': 'true','withFavor': 'false','withShare': 'true','clientType': 'web','clientVersion': '4.0',}response = requests.get(self.url['getMessageList'],params=params,headers=self.headers).json()res=response['result']for r in res:title=r['title']uid=r['docGuid']self.getMessage(uid,path)def getMessage(self,uid,path):params = {'downloadInfo': '1','downloadData': '1','withFavor': 'false','withShare': 'true','clientType': 'web','clientVersion': '4.0','lang': 'zh-cn',}response = requests.get(f'{self.url['getMessage']}{uid}',params=params,headers=self.headers).json()wordCount,imageCount = self.wordCount(response['html'])audioCount = 0print(f"getOK-{path}{response['info']['title']}")if response['resources']:for i in response['resources'] :if 'wiz' not in i['name'] and 'audio.png' in i['name']:imageCount -= 1#音频资源的图标会错误的解析为图片audioCount += int(i['size']/1024/4.5)#音频长度累加 单位:s  粗略估计self.data.append({"path":f"{path}","title":response['info']['title'],"owner":response['info']['owner'],"wordCount":wordCount,"imageCount":imageCount,"audioCount":audioCount,"accessed":response['info']['accessed'],"created":response['info']['created']})def wordCount(self,html):soup = BeautifulSoup(html,'html.parser')for elem in soup(['style', 'script', 'head', 'title', 'meta']):elem.decompose()char_count = len(re.sub(r'\s', '', soup.get_text()))image_count = len(soup.find_all('img'))return char_count,image_countdef showData(self):# for one in self.data:#     print(one)# print(self.data)return self.data#main=wiz(username="admin@wiz.cn",password="123456",domain="http://120.349.12.333:9192")
main.getWizToken()
main.getFolder()
data=main.showData()main.logOut()

大家可以自行运行代码,更改账号密码以及服务器链接就可以查看自己服务器上的文章信息,目前还在开发中…
目前基于这个写了一个文章总览页面,类似Github的代码热力图
在这里插入图片描述
有兴趣的话可以在下一章放出源代码

http://www.lryc.cn/news/589182.html

相关文章:

  • 使用LNMP一键安装包安装PHP、Nginx、Redis、Swoole、OPcache
  • 可微分3D高斯溅射(3DGS)在医学图像三维重建中的应用
  • vllm本地部署qwen3-4b
  • 2.【C# in .NET】探秘数据类型:从底层机制到实战启示
  • 简单2步配置CadenceSkill开发编辑器,支持关键字高亮
  • 正则表达式使用示例
  • Ajax接收java后端传递的json对象包含长整型被截断导致丢失精度的解决方案
  • Flink SQL 性能优化实战
  • Nginx的反向代理
  • 光米投影 多余之物的本思
  • IPM31主板E3300usb键盘鼠标安装成功Sata接口硬盘IDE模式server2003-nt-5.2.3790
  • 服务器上PHP环境安装与更新版本和扩展(安装PHP、Nginx、Redis、Swoole和OPcache)
  • 26.将 Python 列表拆分为多个小块
  • 22.计算指定范围内数字的幂次和
  • 【c++】在const成员函数中使用mutex
  • CCF-GESP 等级考试 2025年6月认证Python四级真题解析
  • 【时时三省】(C语言基础)通过指针引用多维数组
  • mac上的app如何自动分类
  • MongoDB 数据库 启用访问控制
  • GitHub 上 Star 数量前 8 的开源 Web 应用项目
  • AI大模型开发架构设计(22)——LangChain的大模型架构案例实战
  • 飞搭系列 | 子事件流节点,让逻辑复用更简单!
  • error: #147: declaration is incompatible with错误解决
  • 从OSI到TCP/IP:Linux网络架构深度解析
  • 【15】MFC入门到精通——MFC弹窗提示 MFC关闭对话框 弹窗提示 MFC按键触发 弹窗提示
  • OpenCV图像自动缩放(Autoscaling)函数autoscaling()
  • 如何加固Web服务器的安全?
  • Volo-HTTP 0.4.0发布:正式支持 HTTP/2,客户端易用性大幅提升!
  • python学习---dayday6
  • AbMole小课堂 | Angiotensin II(血管紧张素Ⅱ)在心血管研究中的多元应用