正则表达式

z9z8z8z 2009-09-03 03:05:34
http://library.cuhk.edu.hk/search~S15/?searchtype=d&searcharg=+life&searchscope=15&SORT=DZ&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=X+life%26SORT%3DDZ


我要取得东西是Life -- 5 Related Subjects
Life.
Life after death -- 2 Related Subjects
Life among the lowly. -- See Uncle Tom's cabin.
Life and adventures of Martin Chuzzlewit. -- See Martin Chuzzlewit.
Life and adventures of Robinson Crusoe. -- See Robinson Crusoe.
Life and death of King John -- See King John
Life and death of King Richard the Second. -- See King Richard II.
Life and death of the mayor of Casterbridge. -- See Mayor of Casterbridge.
Life and death, Power over -- See also the narrower term Right to die
Life and death, Power over.
Life and death, Power over -- Decision making.


...全文
68 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
z9z8z8z 2009-09-03
  • 打赏
  • 举报
回复
谢谢了
CNCPT01 2009-09-03
  • 打赏
  • 举报
回复
页面有问题 发表后多加了空格.

<?php

$str = file_get_contents('http://library.cuhk.edu.hk/search~S15/?searchtype=d&searcharg=+life&searchscope=15&SORT=DZ&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=X+life%26SORT%3DDZ');


preg_match_all('#<td\s*class\s*=\s*["\']browseEntryData["\'][^>]*?>(.*?)</td>#is', $str, &$matches);
var_dump($matches[1]);

foreach((array)$matches[1] as $v)
{
echo strip_tags($v).'<br />';
}

?>

z9z8z8z 2009-09-03
  • 打赏
  • 举报
回复
七楼你的正则表达式运行出来是array(0) { } 的呀
CNCPT01 2009-09-03
  • 打赏
  • 举报
回复
<?php

$str = file_get_contents('http://library.cuhk.edu.hk/search~S15/?searchtype=d&searcharg=+life&searchscope=15&SORT=DZ&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=X+life%26SORT%3DDZ');


preg_match_all('#<td\s*class\s*=\s*["\']browseEntryData["\'][^>]*?>(.*?)</td>#is', $str, &$matches);
var_dump($matches[1]);

foreach((array)$matches[1] as $v)
{
echo strip_tags($v).'<br />';
}

?>
程序猿之殇 2009-09-03
  • 打赏
  • 举报
回复

$str = strip_tags(file_get_contents("http://library.cuhk.edu.hk/search~S15/?searchtype=d&searcharg=+life&searchscope=15&SORT=DZ&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=X+life%26SORT%3DDZ"), "<td>");
preg_match_all("/<td class=\"browseEntryData\">([^<>]+)<\/td>/ims", $str, $matches);
var_dump($matches);
gqs2105 2009-09-03
  • 打赏
  • 举报
回复
顶贴~!

随便做下广告
PHP MYSQL CMS交流群88286077
z9z8z8z 2009-09-03
  • 打赏
  • 举报
回复
Life -- 5 Related Subjects
Life.
Life after death -- 2 Related Subjects
Life among the lowly. -- See Uncle Tom's cabin.
Life and adventures of Martin Chuzzlewit. -- See Martin Chuzzlewit.
Life and adventures of Robinson Crusoe. -- See Robinson Crusoe.
Life and death of King John -- See King John
Life and death of King Richard the Second. -- See King Richard II.
Life and death of the mayor of Casterbridge. -- See Mayor of Casterbridge.
Life and death, Power over -- See also the narrower term Right to die
Life and death, Power over.
Life and death, Power over -- Decision making.
内容一共是12个 我想用正则表达式把它提取出来谢谢了
iamability 2009-09-03
  • 打赏
  • 举报
回复
我看了,还是楼主提示吧
z9z8z8z 2009-09-03
  • 打赏
  • 举报
回复
上面有地址 打开地址就知道了
iamability 2009-09-03
  • 打赏
  • 举报
回复
在下不才,看不懂楼主想干嘛

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧