Opa Thanks for the guide. I found a solution in jQuery , basically it is an external service where it requests the site I want to query and returns a json object with the site information (variavel.status ) or the Html of the site.
I also found a solution in PHP that does something similar, but that gathers more information and does not need an external service. I'll leave the code here for those who have to build a similar solution.
In JavaScript:
$.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://www.facebook.com') + '&callback=?', function(data){
if(data){
console.log(data.status);
}else{
return("servidor offline");
}
});
<!DOCTYPE html>
<html>
<head>
<title>Angular Curl</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script></head><body><h3style="text-align: center">Mostre o Console para ver o Retorno do Objeto</h3>
</body>
</html>
And below in PHP:
<!DOCTYPE html>
<html>
<head>
<title>Ping Site</title>
</head>
<body>
<?php
function curl_info($url){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_HEADER, 1);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
// curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
$content = curl_exec( $ch );
$info = curl_getinfo( $ch );
return $info;
}
$site = 'http://www.honda.com/';
$info = curl_info( $site );
if( $info['http_code']==200 || $info['http_code']==302 || $info['http_code']==301) {
echo '<u>'.$site . "</u> - <b style='color:lightgreen; font-size: 18px; text-transform: uppercase'>está no ar!!</b><br />";
var_dump($info);
} else {
echo '<u>'.$site . "</u> - <b style='color:red; font-size: 18px; text-transform: uppercase'>está fora do ar!!</b><br />";
var_dump($info);
}
?>
</body>
</html>