2
我使用這個庫(PHP簡單的HTML DOM解析器)來解析鏈接,下面的代碼:解析輸出使用PHP簡單的HTML DOM解析器
print_r($html . "\n");
:
$htmlUrl = 'http://trailers.apple.com/trailers/independent/thelook/includes/playlists/web.inc';
$html = file_get_html($htmlUrl);
當我與打印
輸出我這個(HTML樹):
<h2>
<span class="dropdown-handle" id="trailers-handle">
<span id='single-trailer-info'>Info</span>
<span class='button'>
...
然後我想找到一個元素枝條類(下拉列表):
print_r($divList);
輸出我這個(陣列):
$divList = $html->find('.dropdown-list'); // tried find('.dropdown-list', 0);
然後,我打印
simple_html_dom_node Object
(
[nodetype] => 1
[tag] => div
[attr] => Array
(
[class] => dropdown-list
)
[children] => Array
...
和需要永遠解析!
我做錯了什麼? 一些鏈接具有此輸出(數組)而不是輸出(html樹)。
感謝您的幫助:)
是的,這是它的行爲,它試圖獲得這些元素遞歸,是的它會變得又大又慢 – Ghost