采集X站,仅提供学习

<?php
/**
 * curl 获取网页源码函数
 * @param $url 目标页面 URL
 * @return 页面源码
 */
function curl($url){ 
    $ch = curl_init(); 
    $timeout = 30; 
    $ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36';
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_ENCODING, "");
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);   // 伪造ua 
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); // 取消gzip压缩
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    $content = trim(curl_exec($ch)); 
    curl_close($ch); 
    return $content; 
}
header('Content-type: text/html; charset=utf-8');
$content = curl('http://zy2.pu1.pw:8811');

preg_match_all('/<img onerror="(.*)" width="200" height="135" src="(.*)" alt="(.*)"\/>/sU', $content, $imgsrc);
preg_match_all('/<span class="video-title">(.*)<\/span><div class="video-details">/sU', $content, $title);
echo '
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>采集x站</title>
<style>
body{list-style-type: none;margin: 0;padding: 0;}
.container{width: 100%;}
.row{}
.col-md-12{width:100%}
.col-md-12{float: left;}
.col-md-12,.col-sm-12,{position: relative;min-height: 1px;padding-right: 15px;padding-left: 15px;}
.content, .panel, .breadcrumb{border:none !important;-webkit-background-clip: padding-box;-moz-background-clip: padding-box;background-clip: padding-box;}
.panel{margin-bottom: 5px;}
.panel{margin-bottom:20px;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
.panel-watched{max-height: none;}
.panel-body{box-radius: 0 0 5px 5px;}
.panel-padding{padding: 10px 5px;}
.videos{list-style-type: none;}
.videos li{width: 202px;margin: 0 6px 0 6px;display: inline-block;list-style-type: none;margin: 0;padding: 0;}
.albums li, .photos li, .models li, .channels li, .playlists li{float: left;width: 90%;height: auto;margin: 0 4px 0 4px;}
.video, .user, .category, .album, .photo, .model, .channel, .playlist{position: relative;}
.video a, .user a, .category a, .album a, .photo a, .model a, .channel a, .playlist a{text-decoration: none;}
.thumbnail{background: #1d1d1d;box-shadow: none;background-image: none;border: none;border-radius: 0;padding: 0;padding-bottom: 5px;}
.jumbotron .h1,.jumbotron h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:border .2s ease-in-out;-o-transition:border .2s ease-in-out;transition:border .2s ease-in-out}
a{color: #d8d8d8;}
a:hover{color:#fff;}
.video-thumb{position: relative;overflow: hidden;}
ul.videos li a div.video-thumb img{width: 202px;height: 136px;}
.video-title{width: 95%;}
.video-title{color: #ff1e2b;}
.video-title, .playlist-title{width: 94%;padding: 0 3%;overflow: hidden;height: 18px;line-height: 130%;text-align: left;margin: 4px 0;display: block;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-body panel-padding panel-watched">
<ul class="videos videosf">
';
for ($i=0; $i< 49; $i++) {
	//取图片链接
	preg_match('/src="(.*)"/U', $imgsrc[0][$i], $img);
	$video['img'] = $img[1];
	//取影片名称
	preg_match('/video-title">(.*)<\/span>/U', $title[0][$i], $name);
	$video['name'] = $name[1];
	//取影片链接
	$url = str_replace("1.jpg","index.m3u8",$video['img']);
	$video['url'] = $url;
echo '
<li>
<div class="video">
<a rel="external nofollow" target="_blank" href="https://iooqp.cn/wp-content/themes/begin/go.php?url=aHR0cDovL2FwaS5tdzAueHl6L2p4L20zdTgucGhwP3VybD0nLiR2aWRlb1sndXJsJ10uJw==" title="" target="_blank" class="thumbnail">
<div class="video-thumb">
<img width="200" height="135" src="'.$video['img'].'" alt="">
</div>
<span class="video-title">'.$video['name'].'</span>
</a>
</div>
</li>
';
}
echo '
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
';
?>
阿强爱分享
  • 本文由 发表于 2018年7月17日23:39:06
  • 转载请务必保留本文链接:https://iooqp.cn/68.html
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

评论:2   其中:访客  2   博主  0
    • 王建民 王建民 2

      看看卡

      • 夏午 夏午 0

        老劳模