当前位置: 首页 > 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://catsup.aaladrg.cn
http://adolesce.aaladrg.cn
http://breton.aaladrg.cn
http://adulthood.aaladrg.cn
http://beatster.aaladrg.cn
http://beechwood.aaladrg.cn
http://bespeak.aaladrg.cn
http://cccs.aaladrg.cn
http://assertor.aaladrg.cn
http://blacklist.aaladrg.cn
http://ablaut.aaladrg.cn
http://almoner.aaladrg.cn
http://cardamom.aaladrg.cn
http://buskin.aaladrg.cn
http://asuncion.aaladrg.cn
http://casemate.aaladrg.cn
http://attaboy.aaladrg.cn
http://butyrometer.aaladrg.cn
http://acaridan.aaladrg.cn
http://cacodyl.aaladrg.cn
http://centenarian.aaladrg.cn
http://candour.aaladrg.cn
http://chloroplast.aaladrg.cn
http://boycott.aaladrg.cn
http://assheadedness.aaladrg.cn
http://bibliotherapy.aaladrg.cn
http://befitting.aaladrg.cn
http://carcake.aaladrg.cn
http://bullhorn.aaladrg.cn
http://caragana.aaladrg.cn
http://www.dtcms.com/a/281772.html

相关文章:

  • AI大模型开发架构设计(22)——LangChain的大模型架构案例实战
  • 记忆力训练day41
  • 1-Nodejs介绍与安装
  • 基于STM32的智能火灾报警系统设计
  • 【人工智能99问】激活函数有哪些,如何选择使用哪个激活函数?(5/99)
  • ADAU系列DSP用MCU来做控制,怎么去理解这个逻辑
  • Vue3 + MapLibre 地图管理工具 useMap 使用指南
  • 牛客:HJ22 汽水瓶[华为机考][数字处理]
  • 基于Sentinel-1雷达数据的洪水动态监测(附完整GEE代码)
  • 深入理解红锁
  • Vue3入门-指令补充
  • 学习C++、QT---26(QT中实现记事本项目实现文件路径的提示、C++类模板、记事本的行高亮的操作的讲解)
  • 面向对象与面向过程、函数式编程
  • C++回顾 Day8
  • 【时时三省】(C语言基础)通过指针引用多维数组
  • 【09】MFC入门到精通——MFC 属性页对话框的 CPropertyPage类 和 CPropertySheet 类
  • burpsuite使用中遇到的一些问题(bp启动后浏览器无法连接)/如何导入证书
  • css实现烧香效果
  • 20.如何在 Python 字典中找到最小值或最大值的键?
  • 【卡尔曼滤波第六期】集合变换卡尔曼滤波 ETKF
  • 【Linux庖丁解牛】— 保存信号!
  • HTML网页结构(基础)
  • 【linux V0.11】init/main.c
  • 函数指针与指针函数练习讲解
  • 9、线程理论1
  • HostVDS 云服务器测评:平价入门、流媒体解锁全美、表现稳定
  • 暑假Python基础整理 --异常处理及程序调试
  • Redis 中的持久化机制:RDB 与 AOF
  • Java之Stream其二
  • 第二章 OB 存储引擎高级技术