php文章采集
自家用的 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 "<br>";
@sava_data(new_content(getcontent($getreal),$r_type,$encode_end),$type,$admin,$ztype);
$c_total++;
}
echo "共采集".($c_total)."篇文章";
echo "<a href=# onclick=\"javascript:history.back();\">Back</a>";
//print_r( new_content(getcontent('http://www.diybl.com/course/4_webprogram/php/phpshil/2007828/69928.html'),'aa','aa'));
//echo 'x iloveyou<p></p><br>ffdafdafds';
function getcontent($url)
{
$retmsg=file_get_contents($url);
return $retmsg;
}
function new_content($retmsg,$replace,$class){
$r_type="-ddd";
$start ="<input type=\"button\" value=\"ss索\" onClick=\"tosearch(document.all.wd2);\"><p>";
$end ="<strong><font color=\"#CC0000\">sss落</font></strong>";
$arr1 =explode($start,$retmsg);
$arr2 =explode($end,$arr1[1]);
$ts =preg_replace("/<a href=(.+?)[^>]*>/","",$arr2[0]);/* 清除连接<a href=(.+?)[^>]*>*/
$ts =preg_replace("/<img [^>]*>/im","",$arr2[0]);/* 清除连接*/
$ts =@str_replace("(sss",'',$ts);
preg_match('/<TITLE>(.+?)<\/TITLE>/', $retmsg, $arr);/* 取得标题*/
$p =@str_replace("$replace",'',$arr[1]);
$ts =substr($ts,0,strlen($ts)-70);
return $value =array($p,$ts);
}
function sava_data($lvalue,$type,$admin,$ztype){
$tsql ="select * from filecontent where title='".addslashes($lvalue[0])."'";
$result =mysql_query($tsql) or die(mysql_error());
if(!mysql_num_rows($result)){
$title_ =strip_tags($lvalue[0]);
$content_ =addslashes($lvalue[1]);
@mysql_query("Insert into filecontent(title,content,filesendid,filesendtime,siteindex,systype,z_type) value('$title_','$content_','$admin','".date("Y-m-d")."','1','$type',$ztype)") ;
}}
原创:www.226511.com
补充:Php教程,Php常用代码