求一下正则怎么写
http://www.nhdali.com/zsxx/news02.php 想要匹配这里的 ‘招商和经济动态栏目’ 写了半天也写不出来, 差不多是‘
’ 和 ‘
’ 之间的内容.
——解决方案——————–
这里面还有分页啊
——解决方案——————–
还没人回你?看来剩下我比较闲
/(?:
)([\s\S]+)(?:
)/iU
——解决方案——————–
$con=file_get_contents(“http://www.nhdali.com/zsxx/news02.php?page=”.$_GET[id]);
$preg=”#
——解决方案——————–
$con=file_get_contents(“http://www.nhdali.com/zsxx/news02.php?page=”.$_GET[id]);
$preg=”#
(.*)
#iUs”;
preg_match_all($preg,$con,$arr);
preg_match_all($preg,$con,$arr);
——解决方案——————–
- PHP code
$str = file_get_contents("http://www.nhdali.com/zsxx/news02.php");$match = "/<strong>]*?>(.*?)(.*?)<\/em>.*?<small>([^<]*?)</is";preg_match_all($match , $str , $arr);var_dump($arr);<br /><font color='#e78608'>------解决方案--------------------</font><br />估计写完这个内容匹配,还要写每个具体<div>本文来*源gaodai^.ma#com搞#代!码网</div><pre>搞gaodaima代码
的信息的标题、内容、url解析吧!
这个用dom+xpath比你分析一遍然后再分析一遍要好的多!
另外推荐下4楼得正则,把你要的所有内容都找到了!
——解决方案——————–
——解决方案——————–
——解决方案——————–
$str_pre=’/
\s*\s*(.*?)<\/a>(.*?)\s*(.*?)<\/em>\s*<\/span>\s*(([\w\W]*?)|(.*?))<\/small>/’;
用这个可以匹配到!
用这个可以匹配到!