0

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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Correct. If you disable JavaScript, the page displays nothing else than a warning: This site makes extensive use of JavaScript. Please enable JavaScript in your browser.
Is there any way I could parse this then, if its shown by JavaScript?
1

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

2 Comments

anything, the element you are finding in the code is not in the dom. and also make it pad2 to see it work $html->find('div.pad2');
In my situation I user $html->find('div.pad2'); instead of $html->find('div .pad2'); so I got rid of the error. The space in between is very important to note

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.