最新消息: 新版网站上线了!!!

php采集糗事百科 手机版

header("Content-type:text/html;charset=utf-8");
$snoopy = new Snoopy();
$snoopy->agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405';
$snoopy->fetch('http://www.qiushibaike.com/');
$result = htmlspecialchars($snoopy->results);
$results = $snoopy->results;
 
preg_match_all("/(.*?)<\/a>/i",$results,$a);
preg_match_all("/
([\s\S]+?)<\/article>/iSU",$results,$article);
 
foreach($article[0] as $key=>$val) {
preg_match_all("/
(.*)<\/div>/isU",$val,$content);
preg_match_all("/
}
$count =count($content[0]);
$k = range(0,$count);
foreach($k as $key=>$b) {
$new[$key]['content'] = '';
$new[$key]['img'] = '';
}
foreach($content[0] as $key=>$value) {
$new[$key]['content'] = $value;
}
foreach($img[0] as $key=>$value) {
$new[$key]['img'] = $value;
}
foreach($new as $key => $value) {
echo $new[$key]['img'].'
';
echo $new[$key]['content'];
 
 
}

转载请注明:谷谷点程序 » php采集糗事百科 手机版