Browse Source

文章匹配小程序优化

xueyiming 5 months ago
parent
commit
6ea10e505d

+ 0 - 110
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/other/VideoDownloader1.java

@@ -1,110 +0,0 @@
-package com.tzld.piaoquan.longarticle.utils.other;
-
-import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpUtil;
-import cn.hutool.http.HttpResponse;
-import com.alibaba.fastjson.JSONObject;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-public class VideoDownloader1 {
-    public static void main(String[] args) {
-        // 视频下载链接
-        String videoUrl = "https://www.douyin.com/aweme/v1/play/?video_id=v0200fg10000ctj1failjht1sbj70020&ratio=1080p&line=0";
-
-//        // 设置代理
-//        String proxyHost = "http://t11983523373311:mtuhdr2z@l901.kdltps.com:15818/";
-//        int proxyPort = 15818; // 代理端口
-//
-//        // 创建代理配置
-//        System.setProperty("http.proxyHost", proxyHost);
-//        System.setProperty("http.proxyPort", String.valueOf(proxyPort));
-//        System.setProperty("https.proxyHost", proxyHost);
-//        System.setProperty("https.proxyPort", String.valueOf(proxyPort));
-
-        // 下载视频
-        Map<String, String> map = requestHeader("dy_search", videoUrl, "video");
-        HttpResponse response = HttpUtil.createGet(videoUrl)
-                .addHeaders(map)
-                .execute();
-        System.out.println(response);
-        // 检查响应状态
-        if (response.getStatus() == 200) {
-            // 保存文件到本地
-            File videoFile = new File("/Users/shimeng/Desktop/videos/downloaded_video.mp4");
-            HttpUtil.downloadFile(videoUrl, videoFile);
-            System.out.println("视频下载成功,保存为:" + videoFile.getAbsolutePath());
-        } else {
-            System.out.println("下载失败,状态码:" + response.getStatus());
-        }
-    }
-
-    public static Map<String, String> requestHeader(String platform, String url, String downloadType) {
-        Map<String, String> headers = new HashMap<>();
-
-        switch (platform) {
-            case "xg_search":
-                if (url.contains("v9-xg-web-pc.ixigua.com")) {
-                    headers.put("Accept", "*/*");
-                    headers.put("Accept-Language", "zh-CN,zh;q=0.9");
-                    headers.put("Host", "v9-xg-web-pc.ixigua.com");
-                    headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                    headers.put("Origin", "https://www.ixigua.com/");
-                    headers.put("Referer", "https://www.ixigua.com/");
-                } else if (url.contains("v3-xg-web-pc.ixigua.com")) {
-                    headers.put("Accept", "*/*");
-                    headers.put("Accept-Language", "zh-CN,zh;q=0.9");
-                    headers.put("Host", "v3-xg-web-pc.ixigua.com");
-                    headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                    headers.put("Origin", "https://www.ixigua.com/");
-                    headers.put("Referer", "https://www.ixigua.com/");
-                } else if ("cover".equals(downloadType)) {
-                    headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
-                    headers.put("Accept-Language", "en,zh;q=0.9,zh-CN;q=0.8");
-                    headers.put("Cache-Control", "max-age=0");
-                    headers.put("Proxy-Connection", "keep-alive");
-                    headers.put("Upgrade-Insecure-Requests", "1");
-                    headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36");
-                } else {
-                    headers.put("Accept", "*/*");
-                    headers.put("Accept-Language", "zh-CN,zh;q=0.9");
-                    headers.put("Host", "v3-xg-web-pc.ixigua.com");
-                    headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                    headers.put("Origin", "https://www.ixigua.com/");
-                    headers.put("Referer", "https://www.ixigua.com/");
-                }
-                break;
-
-            case "baidu_search":
-                headers.put("Accept", "*/*");
-                headers.put("Accept-Language", "zh-CN,zh;q=0.9");
-                headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                break;
-
-            case "wx_search":
-                headers.put("Accept", "*/*");
-                headers.put("Accept-Language", "zh-CN,zh;q=0.9");
-                headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                headers.put("Origin", "https://mp.weixin.qq.com");
-                headers.put("Referer", "https://mp.weixin.qq.com");
-                break;
-
-            case "dy_search":
-                headers.put("accept", "*/*");
-                headers.put("accept-language", "en,zh;q=0.9,zh-CN;q=0.8");
-                headers.put("priority", "i");
-                headers.put("range", "bytes=0-");
-                headers.put("referer", "https://v11-coldf.douyinvod.com/");
-                headers.put("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
-                break;
-
-            default:
-                // 其他平台的默认处理
-                break;
-        }
-        return headers;
-    }
-
-}