Извличане на данни от сайт

Illusion

Registered
Искам да извлека тези неща (удебелените) от тук - http://whatismyipaddress.com/ip/65.24.77.25#General-IP-Information

Proxy: None detected (В зависимост дали IP-то е на прокси или не)
Assignment: Dynamic IP (В зависимост дали IP-то е динамично или статично)
Country: United States us flag (Името на държавата + флага й)
City: Delaware (Името на града)

Разбира се, не винаги IP-то е това, което съм дал така, че да се извличат данните за всякакви IP-та.
 
Код:
<?php
$url="http://whatismyipaddress.com/ip/65.24.77.25#General-IP-Information";
$info=@file_get_contents($url);
$ex=explode('<li><a href="#General-IP-Information">', $info);
$ex2=explode('<h2 id="WHOIS-Information" style="padding-top:20px;">', $ex[1]);
$ex=$ex2[0];

$prox=explode("<tr><th>Organization:</th><td>Road Runner</td></tr>", $ex);
$proxy=explode("<tr><th>Type:", $prox[1]);
$proxy=$proxy[0];


$cit=explode("<tr><th>State/Region:</th>", $ex);
$city=explode("<tr><th>Latitude:</th>", $cit[1]);
$city=$city[0];
$city=explode("City", $city);
$city=$city[1];
$city=str_replace($city, "City$city", $city);

$coun=explode("</form>", $ex);
$count=explode("<tr><th>State/Region:</th>", $coun[1]);
$count=$count[0];
$count=str_replace('<h2 id="Geolocation-Information">Geolocation Information</h2>', '', $count);
$count=str_replace('<table>', '', $count);


$ass=explode("</a></td></tr>", $ex);
$assig=explode("<tr><th>Blacklist:</th>", $ass[1]);
$assig=$assig[0];
$assig=preg_replace("/a href='(.+?)'/", "a href='http://whatismyipaddress.com$1'", $assig);

echo $proxy."<br />";
echo $assig."</a><br />";
echo $count."<br />";
echo $city;

?>
 
Трябва ми да взима само и единствено удебелените резултати, а и кода не работи както трябва при останалите IP-та, тъй като си написал:
Код:
<tr><th>Organization:</th><td>Road Runner</td></tr>
 
Код:
<?php
$ipAddress = $_SERVER['REMOTE_ADDR'];
// $ipAddress = '65.24.77.25';

$get = file_get_contents('http://whatismyipaddress.com/ip/' . $ipAddress . '#General-IP-Information');
$proxy1 = explode('<tr><th>Proxy:</th><td>', $get);
$proxy2 = explode('</td></tr><tr><th>Type:</th>', $proxy1[1]);
preg_match('/<tr><th>Assignment:<\/th><td><a href=\'\/dynamic-static\'>(.*)<\/a><\/td><\/tr>/', $get, $preg_assignment);
preg_match('/<tr><th>Country:<\/th><td>(.*)<\/td><\/tr>/', $get, $preg_country);
preg_match('/<tr><th>City:<\/th><td>(.*)<\/td><\/tr>/', $get, $preg_city);

$proxy = $proxy2[0];
$assignment = $preg_assignment[1];
$country = $preg_country[1];
$city = $preg_city[1];
printf('IP Address: <strong>%s</strong><br /><br />Proxy status: <strong>%s</strong><br />Assignment: <strong>%s</strong><br />Country <strong>%s</strong><br />City <strong>%s</strong>', $ipAddress, $proxy, $assignment, $country, $city);
?>
 

Back
Горе