小红书去水印软件_rust开源

源码:

use std::io;
use std::io::copy;
use std::io::Read;
use std::fs;
use std::fs::File;
use regex::Regex;
use reqwest;
use reqwest::Client;
use libwebp::WebPDecodeRGBA;
use image::{ImageBuffer, DynamicImage, Rgba};
 
fn main() {
    loop {
        let mut url = String::new();
        println!("请输入链接:");
        io::stdin().read_line(&mut url).expect("读取输入时出错");
        url = url.trim().to_string();
        if !url.starts_with("http") {
            println!("链接输入错误,应以\"http\"开头");
            continue;
        }
 
        let client = Client::new();
        let mut response = client
            .get(&url)
            .header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 ")
            .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36")
            // 这里填你自己的小红书cookie
            .header("cookie", "")
            .send()
            .unwrap();
        let body = response.text().unwrap();
         
        let title_re = Regex::new(r#"<title>(.*?)<"#).unwrap();
        let title = title_re.captures(&body).and_then(|caps| caps.get(1)).map(|m| m.as_str());
         
        let videos_re = Regex::new(r#","(http.*?mp4)""#).unwrap();
        let video = videos_re.captures(&body).and_then(|caps| caps.get(1)).map(|m| m.as_str());
 
        let images_re = Regex::new(r#"CRD_WM_WEBP","url":"(.*?)""#).unwrap();
        let images: Vec<&str> = images_re.captures_iter(&body).map(|caps| caps.get(1).unwrap().as_str()).collect();
         
        if let Some(title) = title {
            let mut dir_name = format!("{}", title);
            dir_name.retain(|c| c.is_alphanumeric() || c == '_' || c == '-');
            let _ = fs::create_dir_all(&dir_name);
             
            if let Some(video_url) = video {
                let video_filename = format!("{}/{}.mp4", dir_name, title);
                let v_url = video_url.replace(r"\u002F", "/");
                let mut resp = reqwest::get(&v_url).unwrap();
                let mut video_file = File::create(video_filename.clone()).unwrap();
                copy(&mut resp, &mut video_file).unwrap();
                println!("{}.mp4    ok", title);
                continue;
            }
             
            let mut image_counter = 0;
            for image in &images {
                let image_url = image.replace(r"\u002F", "/");
                let mut resp = reqwest::get(&image_url).unwrap();
                let mut buffer: Vec<u8> = Vec::new();
                resp.read_to_end(&mut buffer).unwrap();
                 
                let data: &[u8] = &buffer;
                let (width, height, buf) = WebPDecodeRGBA(data).unwrap();
                let image_buffer: ImageBuffer<Rgba<u8>, Vec<u8>> = ImageBuffer::from_vec(width, height, buf.to_vec()).unwrap();
                let image = DynamicImage::ImageRgba8(image_buffer);
 
                let image_filename = format!("{}/{}.jpg", dir_name, image_counter);
                image.save(image_filename.clone()).unwrap();
                println!("{}.jpg    ok", image_counter);
                image_counter += 1;
            }
        }
    }
}

现成:

图片[1]-小红书去水印软件_rust开源

想要去除小红书上的水印?不用担心!给你推荐一个基于Rust开源去水印的方法,帮助你轻松去除小红书中的水印,解决你的困扰。快来试试吧!

地址:

------本页内容已结束,喜欢请分享------
温馨提示:由于项目或工具都有失效性,如遇到不能做的项目或不能使用的工具,可以根据关键词在站点搜索相关内容,查看最近更新的或者在网页底部给我们留言反馈。
© 版权声明
THE END
喜欢就支持一下吧
点赞1223 分享
评论 共20条

请登录后发表评论