HTML代码
<div class="wrap_search"> <input type="text" id="url" placeholder="请将APP里复制的视频链接粘贴到这里" autocomplete="off"> <button type="submit" id="button">解析</button> </div>
API源码
<?php header('Content-type:application/json; charset=utf-8'); !empty($_GET['url']) ? $url = $_GET['url'] : exit(json_encode(['code'=>202,"msg"=>"参数错误"],JSON_UNESCAPED_UNICODE)); $api = file_get_contents('https://umapi.top/api/dy.php?url='.$url); $data = json_decode($api,true); echo json_encode($data,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
JS代码
$(document).ready(function(){ $('#button').click(function (){ var text = $('#url').val(); if (text == '') { alert('域名不能为空'); return false; } $.ajax({ url:'api.php', type:'get', dataType:'json', data: {url:text}, beforeSend: function(){ $("#load").html('<div class="preloader"><div class="loader"></div></div>'); $("head").prepend(meta); }, success:function(data){ if (data.code == 200) { var mkhtml = '<div class="mark_title">解析结果</div><div class="water_content"><p>'+data.title+'</p><div class="video"><iframe src="'+data.url+'" width="100%" height="100%" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay" referrerpolicy="no-referrer"></iframe></div><div class="download"><a href="'+data.pic+'" target="_blank" rel="nofollow">封面图片</a><a href="'+data.url+'" target="_blank" rel="nofollow" referrerpolicy="no-referrer">下载视频</a></div></div>'; $(".watermark").html(mkhtml); $("#load").empty(); }else{ alert(data.msg); $("#load").empty(); } } }); }); });
HTML、API、JS都给你们了,剩下的就靠自己了,会的人应该一看就懂,分享给大家学习。
本文转载自:精准像素:11px.cn ,感谢作者分享实用知识