-
Notifications
You must be signed in to change notification settings - Fork 0
/
getfiles.php
34 lines (32 loc) · 969 Bytes
/
getfiles.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
<?php
require('phpQuery-onefile.php');
//得到网页内容
$doc = file_get_contents("http://www.stone365.com/news/maintain.aspx");
$dom = phpQuery::newDocument($doc);
//网页标题
//$title = pq("head > title")->text();
//$title = $dom['head > title']->text();
//获取a
$a = pq('ul li')->find('a');
foreach($a as $key){
$url = pq($key)->attr('href');
$t = pq($key)->text();
//$t = iconv('gbk','utf-8',$content);
$content[$url] = $t;
}
//切割网页内容
/*function get_sub_content($str, $start, $end){
if ( $start == '' || $end == '' ){
return;
}
$str = explode($start, $str);
$str = explode($end, $str[1]);
return $str[0];
}
//取得代码中所有链接
*/
function get_all_url($code){
//$pat = '/<a(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/i';
preg_match_all('/<a\s+href=[\"|\']?([^>\"\' ]+)[\"|\']?\s*[^>]*>([^>]+)<\/a>/i',$code,$arr);
return array('name'=>$arr[2],'url'=>$arr[1]);
}