forked from jameswatt2008/91pornMobile
/
functions.php
68 lines (49 loc) · 1.66 KB
/
functions.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//error_reporting(0);
#引入模块
require 'lib/phpQuery.php';
require 'lib/QueryList.php';
include "lib/Snoopy.class.php";
use QL\QueryList;
function getList($domain="http://www.91porn.com",$page = 1){
$jinghua = $_COOKIE["jinghua"];
$url = $domain."/video.php?". ($jinghua == 2 ? "" : "category=rf") ."&page=".$page;
//echo $url;
$html = getHtml($url);
//echo $html;
$html = preg_replace('/<span class="title">(.*)/', '', $html);
$rules = array(
//采集id为one这个元素里面的纯文本内容
'pic' => array('.imagechannelhd>a>img,.imagechannel>a>img','src'),
'title' => array('.imagechannelhd>a>img,.imagechannel>a>img','title'),
'link' => array('.imagechannelhd>a,.imagechannel>a','href'),
);
$data = QueryList::Query($html,$rules)->data;
//print_r($data);
return $data;
}
function randIp(){
return rand(50,250).".".rand(50,250).".".rand(50,250).".".rand(50,250);
}
//根据地址,获取视频地址
function getVideo($url){
$html = getHtml($url);
$rules = array(
//采集id为one这个元素里面的纯文本内容
'video' => array('source','src'),
'title' => array('#viewvideo-title','text')
);
$data = QueryList::Query($html,$rules)->data;
//print_r($data);
return $data[0];
}
function getHtml($url){
$ip = randIp();
$snoopy = new Snoopy;
$snoopy->rawheaders["Accept-language"] = "zh-cn"; //cache 的http头信息
$snoopy->rawheaders["Content-Type"] = "text/html; charset=utf-8"; //cache 的http头信息
$snoopy->rawheaders["CLIENT-IP"] = $ip; //伪装ip
$snoopy->rawheaders["HTTP_X_FORWARDED_FOR"] = $ip; //伪装ip
$snoopy->fetch($url);
return $snoopy->results;
}