• 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
  • 相关阅读:
    abp框架 设置GC模式
    陪诊小程序系统平台功能模式
    计算机毕设(附源码)JAVA-SSM佳音大学志愿填报系统
    数据结构-单链表-力扣题
    如何在 Vue.js 中使用 Axios
    5分钟自建数据库可视化平台,在线管理数据库也太方便了~
    如何将RAW格式的磁盘修改为NTFS?教给你三种操作方法
    JAVA基础——day05
    25李沐动手学深度学习v2/填充和步幅
    【Android知识笔记】进程通信(三)
  • 原文地址:https://blog.csdn.net/weixin_52986315/article/details/127292240