Home > Backend Development > PHP Tutorial > 高分!PHP网页抓取的有关问题

高分!PHP网页抓取的有关问题

WBOY
Release: 2016-06-13 10:25:09
Original
1046 people have browsed it

高分!PHP网页抓取的问题
http://www.zootoo.com/petnews/canineheroesamemorialdaysalute-1612
http://www.zootoo.com/petnews/hailtothecatsasalutetofirstfel-1611
http://www.zootoo.com/petnews/mothersdaygiftsforthepetloving-1592
比如这三个网页
第一个是分页内容,不用管分页
需要把正文部分抓取出来,如何处理?
PHP不是很熟,高分求教,谢谢

------解决方案--------------------
留下邮箱,我给你发个例子
------解决方案--------------------

PHP code
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 class="sep_line1 e_push15"></div>~is',$contents,$p);print_r($p[1]);print_r($p[2]);<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template