Page 1 of 1

Error In Getting Text From Another Website Using Span Id

Posted: Mon Dec 29, 2014 9:36 am
by Dasaradh
Hi.

I tried to get Text from another Website using Span I. I use this code

Code: Select all

$dochtml = new DOMDocument();
$dochtml->loadHTML(http://www.adcd.com/abc);  // Note the website url end does not end with ".html,.php,.htm,etc."
$elm = $dochtml->getElementById('spanid1').innerHTML;  // I tried to the get the Text of the Span Id "spanid1"
But it shows error. Can you correct the code, please ?

Thanks to all. :)

Re: Error In Getting Text From Another Website Using Span Id

Posted: Mon Dec 29, 2014 12:02 pm
by twinedev
After you do do the load, do you verify that the source code did properly load? Can you manually go find a span with and id of spanid1?

beyond that, without knowing what code you are working with (the source of the the other site), kind of hard to say.

Re: Error In Getting Text From Another Website Using Span Id

Posted: Fri Jan 02, 2015 8:41 am
by Dasaradh
Thanks for the replay twinedev.

Yes. I Can find the spanid1 manually.

I will show whats on the other site..

<html>
<span id="spanid1">2.456<span>
</html>

And I tried to get that "2.456" using the code

Code: Select all

[syntax=php]$dochtml = new DOMDocument();
$dochtml->loadHTML(http://www.adcd.com/abc); 
$elm = $dochtml->getElementById('spanid1').i nnerHTML;  
But not working.