【www.gdgbn.com--php常用代码】

自家用的 php 采集程序呵呆把它拿出来吧   php采集代码,php 采集器 ,必一下就可能变成php论坛采集程序,自动采集程序 php php采集原理是读取远程文章的内容然后正我们想要用东西,

 set_time_limit(0); //设置文档永不过期

 $url   =$_POST["url"];//URL

 $start   =$_POST["start"];//开始

 $end   =$_POST["end"];//结束

 //$encode_start =$_POST["encode_start"]; //取得内容代码开始

 $encode_end  =$_POST["encode_end"];//取得内容结束

 $type   =$_POST["select"];//主类

 $ztype   =$_POST["select2"];//子类

 $admin   =$_POST["admin"];//用户

 $r_type   =$_POST["type"];

 $c_total  =0;

 

for($i=$start;$i<=$end;$i++){

 $getreal=$url.$i.".html";

 echo $getreal;

 echo "
";

 @sava_data(new_content(getcontent($getreal),$r_type,$encode_end),$type,$admin,$ztype);

 $c_total++;

}

echo "共采集".($c_total)."篇文章";

echo "Back";

 

//print_r( new_content(getcontent("http://www.diybl.com/course/4_webprogram/php/phpshil/2007828/69928.html"),"aa","aa"));

//echo "x iloveyou


ffdafdafds";

function getcontent($url)

 {  

  $retmsg=file_get_contents($url);

  return $retmsg;

 }

 

function new_content($retmsg,$replace,$class){

 $r_type="-ddd";

 $start ="

";

 $end  ="sss落";  

 $arr1 =explode($start,$retmsg);

 $arr2 =explode($end,$arr1[1]);

 $ts  =preg_replace("/]*>/","",$arr2[0]);/* 清除连接]*>*/  

 $ts  =preg_replace("/]*>/im","",$arr2[0]);/* 清除连接*/ 

 $ts  =@str_replace("(sss","",$ts);

   preg_match("/(.+?)<\/TITLE>/", $retmsg, $arr);/* 取得标题*/</p> <p> $p  =@str_replace("$replace","",$arr[1]);</p> <p> $ts  =substr($ts,0,strlen($ts)-70);</p> <p> return $value =array($p,$ts); </p> <p>}</p> <p>function sava_data($lvalue,$type,$admin,$ztype){</p> <p> $tsql ="select * from filecontent where title="".addslashes($lvalue[0]).""";</p> <p> $result =mysql_query($tsql) or die(mysql_error()); </p> <p> if(!mysql_num_rows($result)){  </p> <p>  $title_  =strip_tags($lvalue[0]);</p> <p>  $content_ =addslashes($lvalue[1]);  </p> <p>  @mysql_query("Insert into filecontent(title,content,filesendid,filesendtime,siteindex,systype,z_type) value("$title_","$content_","$admin","".date("Y-m-d")."","1","$type",$ztype)")  ;</p> <p> }}</p> <p>原创:www.111cn.net</p>

本文来源:http://www.gdgbn.com/jiaocheng/14272/