本帖最后由 badyun 于 2019-10-17 10:30 编辑
这个接口不允许跨域,而且播放器加防盗链了,最后还是用php搞了。。。。
[PHP] 纯文本查看 复制代码 <?php
$url = 'http://m.maohaha.com/system/mlooc_play.php?id=36';
$html = file_get_contents($url);
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
}
html,
body {
width: 100%;
height: 100%;
}
body{
padding: 20px;
}
#hls-video{
width:100%;
height:60vw;
}
#content{
border: 1px solid lightgray;
border-bottom: 0;
border-right: 0;
margin-top:20px;
display: flex;
flex-wrap: wrap;
}
#content>div{
width: 50%;
height: 40px;
line-height: 40px;
border-bottom: 1px solid lightgray;
border-right: 1px solid lightgray;
text-align: center;
cursor: pointer;
}
</style>
<title></title>
</head>
<body>
<iframe id="hls-video" src="" frameborder="0"></iframe>
<section id="content">
</section>
<script>
window.onload = () => {
let content = <?php echo $html ?>;
document.title = content.title
let cell = document.getElementById('content')
content.result.forEach((ele,i) => {
ele.url = ele.url.replace('/player/player.php?url=', 'http://jiexi.071811.cc/jx2.php?url=')
let div = document.createElement('div')
div.innerText = ele.collection
div.onclick = ()=>{
let video = document.getElementById('hls-video')
video.setAttribute("src", ele.url)
}
cell.append(div)
// 默认播放第一集
if(i==0){
div.click()
}
});
}
</script>
</body>
</html> |