Home >Backend Development >PHP Tutorial >求解高难正则写法!!!

求解高难正则写法!!!

WBOY
WBOYOriginal
2016-06-23 14:20:261046browse

已经通过curl获取了http://www.autohome.com.cn/77/options.html的html,如何用正则获取html中的以下部分?求高手!

<script type="text/javascript">var keyLink = {...数组内容...};var config = {...数组内容...};var option = {...数组内容...};var color = {...数组内容...};var dealerPrices = {...数组内容...};</script>


回复讨论(解决方案)

$s = file_get_contents('http://www.autohome.com.cn/77/options.html');preg_match('#<scr[^<]+>\s+var keyLink.+</script>#isU', $s, $r);print_r($r);

$s = file_get_contents('http://www.autohome.com.cn/77/options.html');preg_match('#<scr[^<]+>\s+var keyLink.+</script>#isU', $s, $r);print_r($r);

老大得到的结果如下:
Array ( [0] => ) 

怎么可能,因为数据太多,只能截图了

我再试试,也许是我搞错了

的确是我搞错了,感谢老大,对不起了,我太菜了!!!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn