How to get the domain name via IP??
I use GETHOSTBYADDR (' inside put IP '), every time only return IP instead of return domain name, seemingly only input 127.0.0.1 can return domain name, Baidu, and Google are not, this function exactly how to use it!!!!
function GetHost ($IP)
{
Return (Preg_match '/^ (?: 25[0-5]|2[0-4]\d|1\d\d|[ 1-9]\d|\d) (?: [.]
(?: 25[0-5]|2[0-4]\d|1\d\d| [1-9]\d|\d)) {3}$/', $ip))? GETHOSTBYADDR ($IP): false;
}
------Solution--------------------
PHP Code
function getcontent ($url) {$content =file_get_contents ($url); return $content; } function GetResult ($ip) {$pagesize = 10; $page = 1; $url = "http://cn.bing.com/search?q=ip%3a$ip&first= $page"; $result =array (); do {$url = "http://cn.bing.com/search?q=ip%3a$ip&first= $page"; $content =getcontent ($url); $pattern = "/ ([a-za-z0-9\.] *)(?:\ /.*)? <\/cite>/isu "; Preg_match_all ($pattern, $content, $matches); $result =array_merge ($result, $matches [1]); $nextpage =strpos ($content, "next page"); $page = $page + $pagesize; }while ($nextpage); $result =array_values (Array_unique ($result)); return $result; }//Call Method $result=getresult ("220.181.111.85");//$result =getresult ("117.79.93.222");//csdnecho "";p Rint_r ($result);
-