请教大神一个PHP字符串截取的问题

来源:互联网 发布:数据库系统结构模型 编辑:程序博客网 时间:2024/04/29 18:33

我想采集新浪中国奥运地址截图部分的代码,查找了以后发现这段代码在
<!-- 国家奖牌榜 begain -->和<!-- 国家奖牌榜 end -->之间的DIV里边,就想把这个div采集走,于是用了curl采集到了整个网页内容,现在想要吧中间部分提取出来,我尝试过正则跟字符截取,都不成功,可能是我正则写错了
我的代码:
<?php
  $url = 'http://match.2016.sina.com.cn/medal/organisation/CHN';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $content = curl_exec($ch);  
  curl_close($ch);
$pattern="国家奖牌榜 begain -->(.*)<!-- 国家奖牌榜";
preg_match_all($pattern,$content,$match);
print_r($match);

但是失败了,麻烦大神帮我解决一下这个问题
新浪奥运地址http://match.2016.sina.com.cn/medal/organisation/CHN
0 0
原创粉丝点击