John David
John David

Reputation: 12

Get the html from another webpage from another machine

I am trying to get the html of this page: http://213.177.10.50:6060/itn/default.asp and from this page go to 'Drumuri' where the cars is placed. For short I am trying to get that tabel from 'Drumuri ' page. I have tried this code:

<?php
$DOM = new DOMDocument;
$DOM->loadHTML('http://213.177.10.50:6060/itn/default.asp');


$items = $DOM->getElementsByTagName('a');

print_R($items);
?>

And I also tried with cURL, but no results. This my county's website and I think it is very secured so that's why I can not get it's html. Can you please try and give me the right answer. If I can or not and how or why?

Upvotes: 0

Views: 38

Answers (1)

Gab
Gab

Reputation: 3520

You cannot load directly http://213.177.10.50:6060/itn/default.asp because it contains iFrame. The iFrame source is http://213.177.10.50:6060/itn/dreapta.asp

Here is how to go thru the links and find the DRUMURI link:

<?php
$baseUrl = 'http://213.177.10.50:6060/itn/';

$DOM = new DOMDocument;
$DOM->loadHTMLFile($baseUrl.'dreapta.asp');

foreach($DOM->getElementsByTagName('a') as $link) {
    if ($link->nodeValue == 'DRUMURI') {
        echo "Label -> ".$link->nodeValue."\n";
        echo "Link -> ".$baseUrl.$link->getAttribute('href')."\n";
    }
}

->

Label -> DRUMURI
Link -> http://213.177.10.50:6060/itn/drumuri.asp

Upvotes: 2

Related Questions