php使用正则从指定的文本中截取内容~~ 本帖最后由 hft24dq 于 2011-03-01 18:09:57 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 说明下,由于源文件很长,我剪短了一些。或者请打开链接http://www.24dq.com/?brand-showList.html查看源码,看完整的文本。谢谢大家! $str="";//页面的源码需要转义preg_match("/\<div\sclass\=\"page3\"[.\n]*/",$str,$arr); lz是要匹配<div class="page3"></div>里面内容还是匹配到</html>结尾的啦<?php//匹配<div class="page3"></div>$file=file_get_contents('http://www.24dq.com/?brand-showList.html');$pattern='/<div class="page3">(.*?)<\/div> <div id="Foot">/is';preg_match($pattern,$file,$result);print_r($result[1]);?>匹配到</html><?php$file=file_get_contents('http://www.24dq.com/?brand-showList.html');$pattern='/<div class="page3">(.*?)<\/html>/is';preg_match($pattern,$file,$result);print_r($result[1]);?> 你好,我是想从page3到文件尾部!您的第二段我试了下,很接近了,但是css部分和最后的js调用部分没有取到! $url='http://www.24dq.com/?brand-showList.html';$str=file_get_contents($url);preg_match('/(<div\s*class="page3">[\s\S]*?<\/html>$)/',$str,$match);echo '<pre>';echo $match[1];echo '</pre>';look $pattern='/<div class="page3">([\w\W]*?)<\/html>/';正则这样写,是可以的 pdo连接问题? 关于Apache 页面缓存如何在.htaccess中设置 Apache 2.2下配置phpMyAdmin3问题 rawurlencode和urlencode分别应该在什么场合使用?请指点。 ie 访问 嵌入式 linux web server 出错 php怎么循环读取该数据? 如何解密PHP源代码? 关于成都做PHP 关于网页播放视频(急) 请问:如何用PHP动态生成一个下拉菜单 正则 如何匹配特定字符前的数字 并输出最大的 汇付 天下的接口问题
或者请打开链接http://www.24dq.com/?brand-showList.html查看源码,看完整的文本。谢谢大家!
$str="";//页面的源码需要转义
preg_match("/\<div\sclass\=\"page3\"[.\n]*/",$str,$arr);
<?php
//匹配<div class="page3"></div>
$file=file_get_contents('http://www.24dq.com/?brand-showList.html');
$pattern='/<div class="page3">(.*?)<\/div> <div id="Foot">/is';
preg_match($pattern,$file,$result);
print_r($result[1]);
?>
匹配到</html><?php
$file=file_get_contents('http://www.24dq.com/?brand-showList.html');
$pattern='/<div class="page3">(.*?)<\/html>/is';
preg_match($pattern,$file,$result);
print_r($result[1]);
?>
您的第二段我试了下,很接近了,但是css部分和最后的js调用部分没有取到!
$url='http://www.24dq.com/?brand-showList.html';
$str=file_get_contents($url);
preg_match('/(<div\s*class="page3">[\s\S]*?<\/html>$)/',$str,$match);
echo '<pre>';
echo $match[1];
echo '</pre>';look
正则这样写,是可以的