Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a WHOIS lookup with PHP or Python?

Tags:

php

whois

So anyways, I'm working on a small PHP website/script, and as one of the features I'd like to be able to run a WHOIS lookup on the current domain the PHP script is running on.

Ideally, it would be one function that I could call and in the function it would run the WHOIS, and then echo the results to the screen. It would take in the URL of the site to run the WHOIS lookup on, or it would just run it on the current URL/Domain (which is what I want), although I can feed it a variable for the website domain if need be.

I don't know much about WHOIS lookups (well, I know what they do, I just don't know how to run them in PHP), but I'd also be fine with having to query another website (even one of my own if you can give me the code for it).

Whatever works, please just let me know! The main thing is that, I'd prefer it to fit all in one function, and it definitely must fit in one PHP file/document.

like image 713
Alper Avatar asked Jul 18 '11 02:07

Alper


People also ask

How do you use WHOIS in python?

We can use the WHOIS protocol to see who is the registered owner of the domain name. There is a Python module, called python-whois, for this protocol, documented at https://pypi.python.org/pypi/python-whois, which can be installed via pip using the pip install python-whois command. With the pythonwhois. net.

How do I run WHOIS lookup?

Performing WHOIS Lookups To perform a search, users only need to go to http://whois.icann.org, enter a domain name, and click "Lookup."

Does WHOIS have an API?

The Whois Lookup API provides the ownership record for a domain name or IP address with basic registration details. The API is optimized to respond quickly and is designed to handle a high volume of parallel requests.

What is WHOIS lookup tool?

Whois is a widely used Internet record listing that contains the details of who owns a domain name and how to get in touch with them. The contact details can be for both the domain's registrar or the web hosting company providing space or storage for that specific website.


1 Answers

With php you can use shell_exec to execute the whois command.

    <?php
    $whois = shell_exec("whois domain.net");
    echo '<pre>';
    print_r($whois);
    ?>
like image 170
Pavel Petrov Avatar answered Sep 20 '22 06:09

Pavel Petrov