开发者

Find who is hosting a website using PHP

开发者 https://www.devze.com 2023-02-16 15:44 出处:网络
I am developing a website to show information about a website like ip, location, coordinates, flag of country, dns entries and more. I managed to collect everything, but the only thing left is to find

I am developing a website to show information about a website like ip, location, coordinates, flag of country, dns entries and more. I managed to collect everything, but the only thing left is to find who is hosting the website.

I saw in whoishostingthis.com that you could find the name of datacenter or host of any domain which is exactly what i wanted. I did a lot of research on how to collect that data, but nothing worked till now. I know that it has something to do with开发者_Go百科 reverse dns , but i dont know how to get the name of the datacenter using reverse dns.

I could just grab the name of the host from whoishostingthis.com using curl and extract the data, but i dont want to do that as it might violate their tos or something. So, does anyone know how to collect that data? If i could find that anyhow (even using a linux binary or something), i could import that to php.

Any help would be appreciated. Thanks :)

EDIT: Just to let you guys know, i tried using the RESTful API from arin, but the problem is that it can display the organization information about the ip addresses in america, but if it is outside north america, it just displays the regional IP authority. For example, if you go to http://ip.nex.im/?q=wireshock.com , which is hosted in usa, it shows hostdime inc, which is true, but if you go to http://ip.nex.im/?q=www.ovh.co.uk , it just shows "RIPE Network Coordination Centre". You can try other ip's http://ip.nex.im/?q=[IP OR DOMAIN]. And i could not find an api for other regional ip authorities like ripe or others that can display the organization that owns the ip address. If i find something that works, i will make an open api that anyone can use. And if anyone knows any other way, please reply. Thanks :)


I own WhoIsHostingThis.com. We have an API...

http://www.whoishostingthis.com/our-api/

...so PM me/meail me and we'll get you setup ASAP.

Richard


The best way to get this is by going to the source: ARIN

Of course, you can only make educated guesses. Often times, the holder of the IP block will be some bigger ISP that your hosting provider connects to.


<?php 
function ipwhois(){
    $ip_info = 'https://ipwhois.app/json/'.$_SERVER['REMOTE_ADDR'];
    $ch = curl_init();curl_setopt($ch, CURLOPT_URL, $host);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    return curl_exec($ch);
    curl_close($ch); 
 }
 $org = strtolower(json_decode(ipwhois())->org);
 echo $org;
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消