谈不上什么高级的程序,我是菜鸟,简单的说就是把柯林的文章采集到空间指定目录,并保存为文章标题.txt再自己后台上传自己的柯林程序,这是去年学正则的一个作品…没有注释很乱,同时有些标题和文章无法匹配编码问题。下面的采集保存目录是phpjc
index.php
<?php
header("content-type:text/html;charset=utf-8");
?>
<title>柯林文章采集程序</title></head><body><form action="work.php" method="POST">采集的域名:<input name="url" value="http://"/><br/>文章版块id:<input name="classid" value=""/><br/>文章id采集范围:<br/>起:<input name="id" value="" size="1"/><br/>末:<input name="iid" value="" size="1"/><br/><input type="submit" value=">>>采集>>>"/></form>
</body>
</html>
work.php
<?php
header("content-type:text/html;charset=utf-8");
?>
<title>采集状态</title></head><body>
<?
$url=$_POST['url'];
$c=$_POST['classid'];
$id=$_POST['id'];
$iid=$_POST['iid'];
while($id<=$iid)
{
$content=file_get_contents("$url/article/book_view.aspx?siteid=1000&classid=$c&id=$id&lpage=1&sid=-2-0-0-0-0");
$pa='%<div class="title">(.*?)<\/div>(.*?)<div class="content"><p align="center"></p>(.*?)<\/div>%si';
preg_match($pa,$content,$r);
$txt=str_replace
("<br/>","///","$r[3]");
$bt=str_replace(" ",'',$r[1]);
$StatDir=dirname(__FILE__);
$text=$txt;
$file=$bt;
$fp=fopen($StatDir."/phpjc/".$file,"a ");
$stat=$text."\n".$bz;
fputs($fp,$stat);
fclose($fp);
echo "$bt<br/>>>>采集成功<br/>";
$id ;
}
?></HTML>