$message = explode($end,$message[1]); return $message[0];}其中$string为要被切取的内容,$start为开始的地方,$end为结束的地方。取出分类号:
$start = "Html/Book/";
$end
= "List.shtm";
$typeid = cut($typeid[0][0],$start,$end);
$typeid = explode("/",$typeid);[/php]
这样,$typeid[0]就是我们要找的分类号了。接下来就是构造章节列表的地址了:$chapterurl = http://www.86zw.com/Html/Book/.$typeid[0]/$_POST[‘number']/List.shtm。有了这个就能找到每一章节的地址了。方法如下:
$ustart = """;
$uend
= """;
//t表示title的缩写
$tstart = ">";
$tend
= "<";
//取路径,例如:123.shtm,2342.shtm,233.shtm
preg_match_all("/"[0-9]{1,}.(shtm)"/is",$chapterurl,$url);
//取标题,例如:第一章 九世善人
preg_match_all("/<a href="[0-9]{1,}.shtm"(.*?)</a>/is",$file,$title);
$count = count($url[0]);
for($i=0;$i<=$count;$i++)
{
$u = cut($url[0][$i],$ustart,$uend);
$t = cut($title[0][$i],$tstart,$tend);
$array[$u] = $t;
}
$array数组就是所有的章节地址了,到这里,采集器就完成一半了,剩下的就是循环打开每个章节地址,读取,然后将内容匹配出来。这个比较简单,这里就不详细叙述了。好了,今天就先写到这吧,第一次写这么长的文章,语言组织方面难免有问题,还请大家多包涵!







