用php 写一段提取某个网页中的某段的代码

如:网页:http://book.zongheng.com/showchapter/199430.html

取该网页中 <div class="chapter"> 到 <!-- 章节列表 结束 --> 之间的内容包括HTML 代码

请高手帮忙写一段

<?php
//获取网页内容
$str=file_get_contents('http://book.zongheng.com/showchapter/199430.html');
//删除 <div class="chapter">之前的内容
if ($x=strpos($str,'<div class="chapter">')) $str=substr($str,$x);
//删除 <!-- ç« èŠ‚列表 ç»“束 -->之后的内容
if ($x=strpos($str,'<!-- ç« èŠ‚列表 ç»“束 -->')) $str=substr($str,0,$x);
//输出结果
echo $str;
?>
温馨提示:答案为网友推荐,仅供参考
相似回答