php抓取新闻解决方法

WBOY
Release: 2016-06-13 12:19:35
Original
963 people have browsed it

php抓取新闻
我要抓取网页的一部分新闻内容并显示在自己的前台页面上,请问该怎么做呢?
比如在网易上跟家居有关的新闻

引用
$url = "http://home.163.com";
$contents = file_get_contents($url);
//如果出现中文乱码使用下面代码
//$getcontent = iconv("gb2312", "utf-8",$contents);
echo $contents;
?>

上面这代码只是获取全部页面吧
------解决思路----------------------
正则匹配或者用simple_html_dom
看你要哪些内容
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