高分!PHP网页抓取的问题

ebb 2010-06-03 05:01:28
http://www.zootoo.com/petnews/canineheroesamemorialdaysalute-1612
http://www.zootoo.com/petnews/hailtothecatsasalutetofirstfel-1611
http://www.zootoo.com/petnews/mothersdaygiftsforthepetloving-1592
比如这三个网页
第一个是分页内容,不用管分页
需要把正文部分抓取出来,如何处理?
PHP不是很熟,高分求教,谢谢
...全文
200 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dleno 2010-06-07
  • 打赏
  • 举报
回复

header("Content-type:text/html;charset=utf-8");
$url="http://www.zootoo.com/petnews/hailtothecatsasalutetofirstfel-1611";
$contents=file_get_contents($url);
$contents=preg_replace('/>(\s+)/','>',$contents);
$contents=str_replace("\r\n",'',$contents);
$contents=str_replace("\t",'',$contents);
//echo $contents;
preg_match_all('~<div class="f_right" style="width: 175px;">(.*?)</div>(.*?)</div><div class="sep_line1 e_push15"></div>~is',$contents,$p);
print_r($p[1]);
print_r($p[2]);
太久 2010-06-07
  • 打赏
  • 举报
回复
LZ也发我个呗。。
ebb 2010-06-04
  • 打赏
  • 举报
回复
up 一下
ebb 2010-06-03
  • 打赏
  • 举报
回复
eggb4by(AT)yahoo.com.cn,谢谢
jianglin28290 2010-06-03
  • 打赏
  • 举报
回复
留下邮箱,我给你发个例子
ebb 2010-06-03
  • 打赏
  • 举报
回复
我看了下html源码,感觉正则不是很好弄,特别是内容的前面只是一个<div>,请高手指教如何处理
另请附代码,谢谢
liuahuilele 2010-06-03
  • 打赏
  • 举报
回复
用正则
....

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧