- 论坛徽章:
- 1
|
- <?php
- // --------------------------------------------------------------------------
- // File name : testRegex.php
- // Description : 用正则表达式,取得网页正文部分内容,且仅仅保留表格部分的HTML标签
- // Requirement : PHP4 (http://www.php.net)
- //
- // Copyright(C), HonestQiao, 2005, All Rights Reserved.
- //
- // Author: HonestQiao (honestqiao@hotmail.com)
- //
- // --------------------------------------------------------------------------
- echo preg_replace('/<!--.*?-->|<(head|title|script|style)[^>]*?>.*?<\/\1>|\t|(<\/?(?:table|tbody|th|tr|td))[^>]*?(>)|(?:<\/(?!table|tbody|th|tr|td))[^>]*?>|(?:<(?!table|tbody|th|tr|td))[^>]*?>/sim', '$2$3', file_get_contents("http://bbs.chinaunix.net"));
- ?>
复制代码 |
|