tencent_online_get

Crates.iotencent_online_get
lib.rstencent_online_get
version0.1.0
sourcesrc
created_at2024-08-14 08:20:14.715262
updated_at2024-08-14 08:20:14.715262
description一个封装好的自用库
homepage
repository
max_upload_size
id1337012
size47,194
(vintcessun)

documentation

README

一个封装好的库用于获取腾讯在线文档的下载地址

cookie获取方法

先打开腾讯文档并登录后打开F12并输入

function get_tag(tag){var key=tag+"=";var str=document.cookie.slice(document.cookie.indexOf(key)+key.length);return str.slice(0,str.indexOf(";"))}"uid="+get_tag("uid")+";uid_key="+get_tag("uid_key");

然后复制输出内容

1723622466877

这个就是cookie了,删不删除两边的引号无所谓(内部做了替换)

调用方法

use tencent_online_get::{OnlineOpen,ReturnFile}
let cookie = ""
let source_url = ""
let mut f:OnlineOpen = tencent_online_get::OnlineOpen::new(cookie);
let ret = f.get_url(source_url).unwrap();//这里得到了ReturnFile格式的地址
let ret = DownloadFile::new(ret);
ret.download().unwrap();

对于结果的解析可以定义一个这个

struct DownloadFile{
	url: String,
	filename: String,
}

impl DownloadFile{
	fn new(f: ReturnFile)->Self{
		Self{url:f.url,filename:f.filename}
	}
	fn download(&self)->Result<()>{
		println!("下载 {:?} => {:?}",&self.url,&self.filename);
		Ok(())
	}
}

DownloadFile是参照ReturnFile定义的

#[derive(Debug, Clone)]
pub struct ReturnFile{
    pub url: String,
    pub filename: String,
}
Commit count: 0

cargo fmt