Crates.io | tencent_online_get |
lib.rs | tencent_online_get |
version | 0.1.0 |
source | src |
created_at | 2024-08-14 08:20:14.715262 |
updated_at | 2024-08-14 08:20:14.715262 |
description | 一个封装好的自用库 |
homepage | |
repository | |
max_upload_size | |
id | 1337012 |
size | 47,194 |
先打开腾讯文档并登录后打开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");
然后复制输出内容
这个就是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,
}