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

求解高难正则写法!!!

WBOY
Release: 2016-06-23 14:20:26
Original
1054 people have browsed it

已经通过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>
Copy after login


回复讨论(解决方案)

$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);
Copy after login
Copy after login

$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);
Copy after login
Copy after login

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

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

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template