Deda Spale
Deda Spale

Reputation: 3

Why PHP Simple HTML DOM Parser won't find an element?

I'm using PHP Simple HTML DOM Parser with following code snippet:

<?php
include_once('../simple_html_dom.php');

$html = file_get_html('http://old.wowhead.com/npc=8404');

if ( $html->find('div.pin'))
echo 'Found';

?>

But it simply does not find

'<div class="pin" style="left: 17.7%; top: 60.8%; "><a href="javascript:;"     style="cursor: default; "></a></div>' 

element on this html page: http://old.wowhead.com/npc=8404

Upvotes: 0

Views: 2343

Answers (2)

Danil Speransky
Danil Speransky

Reputation: 30473

I think div elements with class pin appears by JavaScript, so when you just download static html file there is no such elements.

Upvotes: 1

Shivam Shah
Shivam Shah

Reputation: 524

i opened the link you gave and there is no div with a class of 'pin'. You have to give the method a valid element object.

try changing the selector to say

$html->find('div.pad1');

it works...in my case

Upvotes: 1

Related Questions