Home > Backend Development > PHP Tutorial > php 网页截取快讯代码

php 网页截取快讯代码

WBOY
Release: 2016-06-13 12:51:50
Original
854 people have browsed it

php 网页截取新闻代码
function Get_news($url,$count)
{
$handle = fopen($url,"r"); 
$c = 0;
while(($line = fgets($handle,1024)) && ($c {
//$ptr2= "/(.*)/";
$ptr= "/
(.*)/";

preg_match_all($ptr,$line,$str,PREG_SET_ORDER);
if($str)
{
$res[$c]= strip_tags($str[0][2]);
//$res[$c][1] = $url."admin/view_n.php?id=".$str[0][1];
$c = $c+1;


}
print_r($res[$c]);
}
return $res;
}




$url = "http://stu.gdmc.edu.cn/";
$count = 7;
//echo"

";
?> 

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