Jump to content

file_get_contents


sandbudd

Recommended Posts

I looked there and tried a few things and it did not work... what I am trying to do is capture the right hand side of www.nflcarswoldwide.net the right hand side with the maps....

 

Well, you need to figure out what the right hand side of that page is (it didn't load for me).  If the info is in a div or a table td, then you load the page into Domdocument and extract the div, td, etc. by name, id or by count, like if is the 3rd td of the second table etc...  Find out what it is and then look at a DOM tutorial to see how to get it.

Link to comment
https://forums.phpfreaks.com/topic/209043-file_get_contents/#findComment-1092142
Share on other sites

Something to do with the DomDocument. Abra would be a much better person to give that information, only because i'm sure he's used the domdocument previously and i never have.

 

though get element by id is what you're looking for...

 

http://us.php.net/manual/en/domdocument.getelementbyid.php

 

 

Link to comment
https://forums.phpfreaks.com/topic/209043-file_get_contents/#findComment-1092183
Share on other sites

DOM might not be the best tool in this case because their markup is invalid. If you want to use DOM you'll have to suppress the warnings generated by their HTML. Here's an example on how it could be done using DOM anyway..

 

$doc = new DOMDocument();
@$doc->loadHTMLFile('http://nflcarsworldwide.net/'); // @ to suppress warnings from their invalid HTML
$temp = new DOMDocument();
foreach ($doc->getElementById('right')->childNodes as $child){
$temp->appendChild($temp->importNode($child, true));
}
echo trim($temp->saveHTML());

Link to comment
https://forums.phpfreaks.com/topic/209043-file_get_contents/#findComment-1092189
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.