-
Notifications
You must be signed in to change notification settings - Fork 0
/
getMoiveLink.class.php
143 lines (113 loc) · 3.83 KB
/
getMoiveLink.class.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
require_once __DIR__.'../simple_html_dom.php';
class getMoiveLink{
public $url = null;
public function __construct($keyword)
{
$keyword = iconv('utf-8','gb2312//IGNORE',$keyword);
$keyword = urlencode($keyword);
$this->url = 'http://s.dydytt.net/plus/so.php?kwtype=0&searchtype=title&keyword='.$keyword;
}
public function getMoiveHandle()
{
$content = $this->curl_post($this->url);
$html = str_get_html($content);
$detail = [];
$detail_url = 'http://www.ygdy8.com';
foreach($html->find('tbody td b a') as $element)
{
$detail[] = $detail_url.$element->href;
}
$res = '';
foreach ($detail as $val) {
# code...
$content = $this->curl_post($val);
$html = str_get_html($content);
$res .= $this->dw_addr($html);
}
if(empty($res)) $res = '没有找到资源或者你输入的电影名字有误';
return $res;
exit;
}
/**
* 获取首页最新电影
* @return [type] [description]
*/
public function getLatest()
{
$url = 'http://www.dytt8.net';
$content = $this->curl_post($url);
$html = str_get_html($content);
$table = $html->find('table',1);
foreach($table->find('tr td a') as $element)
{
if($element->plaintext !='最新电影下载')
{
$name[] = $element->plaintext;
}
}
return $name;
}
function curl_post($url)
{
$headers = array("application/x-www-form-urlencoded","Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","Cache-Control: no-cache","Pragma: no-cache");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回数据不直接输出
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
// curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file); //存储提交后得到的cookie数据
$content = curl_exec($ch); //执行并存储结果
$content = iconv('gb2312','utf-8//IGNORE',$content);
curl_close($ch);
return $content;
}
/**
* 获取下载标题和下载链接
* @param [type] $html [description]
* @return [type] [description]
*/
public function dw_addr($html)
{
$data ='';
if(!$html) return $data;
$url = [];
$title = "\r\n迅雷下载:\r\n";
foreach($html->find('table tr td a') as $element)
{
if(strstr($element->href,'ftp'))
{
$url[] = $this->ftp2thunder($element->href);
}elseif(strstr($element->href,'thunder')){
$url[] = $element->href;
}
}
foreach($html->find('div h1 font') as $element1)
{
$title .= $element1->plaintext;
}
if(!empty($url[0]))
{
$data = $title.": ".$url[0];
}
// $data = [
// 'title'=>$title,
// 'down_url'=>$url
// ];
return $data;
}
/**
* [ftp下载链接转为迅雷链接]
* @param [type] $ftp_link [description]
* @return [type] [description]
*/
public function ftp2thunder($ftp_link)
{
$link = 'AA'.$ftp_link.'ZZ';
$link = base64_encode($link);
$link = 'thunder://'.$link;
return $link;
}
}
?>