php 通用采集入库程序

采集 用到的知识点

file_get_contents()

preg_match_all()

preg_match()

preg_replace()

正则表达式、正则修正符的用法

ls.php文件内容:

$con=file_get_contents("url");

$preg="##iUs"  //正则表达式

preg_match_all($preg,$con,$arr);

foreach($arr[1] as $id=>$v){

       echo $v."  ".$arr[2][$id]."<br>";

}

vi.php内容

$con=file_get_content("url2");

$preg="#<title>(.*)</title>#iUs";

echo zz("#<title>(.*)</title>#iUs",$con);

echo zz("#<!--正文-->#")

preg_match($preg,$con,$arr);

function zz($preg,$con,$num=1){

preg_match($preg,$con,$arr);

return $arr[$num];

}

猜你喜欢

转载自blog.csdn.net/taotaobaobei/article/details/78081448