分类:PHP记事本 发布时间:2017-05-30 10:39:44 阅读: 作者:郑祥景
<?php
//取得指定位址的內容,并储存至 $text
$text=file_get_contents('http://b.tiayo.com/Home/article?aid=122');
//过滤空格
$text = preg_replace('/\s*/', '', $text);
$text = str_replace(array(" "), "", $text);
//开始位置
$start = '<div class="neirongkaishi">';
$start = preg_replace('/\s*/', '', $start);
$start_num = strpos($text, $start)+strlen($start);
//结束位置
$end = '</div><p class="newsediter">';
$end = preg_replace('/\s*/', '', $end);
$end_num = strpos($text, $end);
//要输出的位置
$jiequ = $end_num-$start_num;
// echo $end_num;
echo substr($text,$start_num,$jiequ);
?>
编辑:郑祥景