【发布时间】:2015-05-11 14:10:46
【问题描述】:
我正在使用这个库(PHP Simple HTML DOM parser)来解析链接,代码如下:
$htmlUrl = 'http://trailers.apple.com/trailers/independent/thelook/includes/playlists/web.inc';
$html = file_get_html($htmlUrl);
当我打印时:
print_r($html . "\n");
向我输出这个(html 树):
<h2>
<span class="dropdown-handle" id="trailers-handle">
<span id='single-trailer-info'>Info</span>
<span class='button'>
...
然后我想在类中找到一个元素(下拉列表):
$divList = $html->find('.dropdown-list'); // tried find('.dropdown-list', 0);
然后我打印:
print_r($divList);
给我输出这个(数组):
simple_html_dom_node Object
(
[nodetype] => 1
[tag] => div
[attr] => Array
(
[class] => dropdown-list
)
[children] => Array
...
永远解析!
我做错了吗? 有些链接有这个输出(数组)而不是输出(html树)。
感谢您的帮助:)
【问题讨论】:
-
是的,这就是它的行为,它试图递归地获取这些元素,是的,它会变得又大又慢