• SpringBoot + Thymeleaf打造VIP视频源解析网站


    第一步:创建一个SpringBoot项目

    <dependency>
    	<groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-thymeleafartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-testartifactId>
        <scope>testscope>
    dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    第二步:写一个controller测试接口能否调通

    @Controller
    public class VIPController {
    
        @RequestMapping("/play")
        public String play() {
            return "play";
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    第三步:编写前端页面

    DOCTYPE html>
    <html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css">
        <title>VIP视频title>
    head>
    <body>
    <div id="app">
        <form action="/doPlay" onsubmit="return urlCheck()">
            <div>
                <h2 style="margin:20px auto;text-align: center;color: white">本站点使用第三方提供的解析接口(仅用于学习和交流)h2>
            div>
            <div class="ibox">
                <input class="input" name="url" type="search" placeholder="输入地址(腾讯视频/优酷/爱奇艺)视频地址">
                <input id="ck" type="checkbox" name="isQR" value="true" onclick="changeText()"><label for="ck" style="color: white;padding: 10px">手机观看label>
                <input id="btn" class="button" type="submit" value="在线播放">
            div>
            <div class="codes">
            div>
        form>
    div>
    
    <script>
        function urlCheck() {
            var value = document.querySelector(".input").value;
            if (value == null || value == "") {
                alert("请输入地址")
                return false;
            }
            if (!value.startsWith("http")) {
                alert("请输入正确的http/https链接")
                return false;
            }
            return true
        }
        function changeText(){
            var ck = document.querySelector("#ck").checked;
            if(ck){
                document.querySelector("#btn").value="生成二维码";
            }else{
                document.querySelector("#btn").value="在线播放";
            }
        }
    script>
    
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    第四步:定义一个接口用来解析VIP网站

    @RequestMapping("/doPlay")
    public String doPlay(String url, boolean isQR, HttpServletResponse response) throws IOException {
        if (isQR) {
            String playUrl = "https://jx.bozrc.com:4433/player/?url=" + url;
            BufferedImage image = QrCodeUtil.generate(playUrl, 400, 400);
            // 把图片发送给浏览器
            ImageIO.write(image,"png",response.getOutputStream());
    
        } else {
            return "redirect:https://jx.bozrc.com:4433/player/?url=" + url;
        }
        return null;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    Numpy知识点回顾与学习
    java springboot在当前测试类中添加临时属性 不影响application和其他范围
    Leetcode—2216.美化数组的最少删除数【中等】
    十年架构五年生活-03作为技术组长的困扰
    python 中文字符转换unicode及Unicode 编码转换为中文
    python编译成so文件
    python毕业设计项目源码选题(16)跳蚤市场二手物品交易系统毕业设计毕设作品开题报告开题答辩PPT
    go学习笔记
    Java中如何将“日期字符串”转换为java对象呢?
    【LeetCode】超级洗衣机 [H](贪心)
  • 原文地址:https://blog.csdn.net/weixin_52986315/article/details/127292240