PHP 如何提取网页内容

来源:百度知道 编辑:UC知道 时间:2024/06/27 06:40:35
我要想在
http://bbs.vavay.com/member128715
得到帖子总数:这个数字,如何操作,我写的老是出错
$task = (string) file_get_contents('http://bbs.vavay.com/member128715');
preg_match_all('[\<strong\>0-90-90-9\<\/strong\>]',$task,$matches);
echo $matches;
1楼的不要瞎扯,打广告就打广告咯!!!

PS:页面本身是伪静态的……
不能加斜杠,
我想获取帖子数用正则怎么会提取不到呢?

给你写了个php小偷程序,不算好,只是把关键技术写出来了,不是很完善.
php教程http://www.q266.com/Article6/Q266-49/

<?php
class fetch {
private $url="";
private $dir="";
private $file="";
private $bfile="";
private $cachetime=3600;//缓存储时间
private $content ;//目标的数据,字符串类型
function open (){
if (!$filearray=file($this->url.$this->dir.$this->file))
die ("无法打开目标网页");
$this->content=implode("",$filearray);
}
function check (){
if (!file_exists("./cache/$this->bfile") or (filemtime("./cache/$this->bfile")+$this->cachetime)<time()){
$fp=fopen("./cache/$this->bfile","w");
fwrite($fp,$this->content);
fclose($fp);
}
}

//cut 函数不实用,应该改为正则,我懒得改了,在类外部实现
function cut