How to get expiry date and registrar of a domain

Discussion in 'PHP' started by bobby9101, Jan 10, 2007.

  1. #1
    Hello,
    I have no clue on how to get the expiry date and the registrar of a domain.
    I was wondering how it could be done.
    I am hoping to not have to scrape results from a place like whois.sc
     
    bobby9101, Jan 10, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    without the use of special pear modules installed I think probably whois queries are all you have, I dunno if you'll have the ability to execute it on your webhost, so find a website you can query, I think most dont actually allow, or rather limit automation of queries.
     
    krakjoe, Jan 10, 2007 IP
  3. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So how would I go about scraping results?
    I mean i could (i think this is possible - i am new to php) query whois.sc/$domain
    and use regex or something to fond the expiration date.
    But I really would like to avoid using that.
    There has to be someway to find registrar and expiry date without scraping.
    I would prefer not to use a pear modules also :rolleyes:
     
    bobby9101, Jan 10, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  5. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks nico, i just found that before you posted it though :D
    I was looking through it and from my limited experiance, I can't make heads or tails of it.
    How much would someone charge to make a little scripts that returned:
    
    $expiry = EXPIRY;
    $registrar = REGISTRAR;
    from $domain
    
    PHP:
     
    bobby9101, Jan 10, 2007 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    Nice find nico :)

    
    <?
    # Change to path of phpwhois folder, wherever it is
    define("PHP_WHOIS_PATH" , "phpwhois-4.1.2");
    
    include(PHP_WHOIS_PATH . '/whois.main.php');
    
     function ez( $domain )
     {
    	$whois = new Whois();
    	$data = $whois->Lookup($domain);
    	$return['registrar'] = $data['regyinfo']['registrar'];
    	$return['expires'] = $data['regrinfo']['domain']['expires'];
    	return $return;
     }
    
    
    $test = ez("digitalpoint.com");
    echo "<pre>";
    print_r($test);
    // Just the expires :
    echo $test['expires'];
    echo "<br />\n";
    echo $test['registrar'];
    
    
    PHP:
    If you download that whois script from above and dont worry about what's in it just upload the whole folder to the webserver and then upload and unclude that file in your stuff, when ( I assume ) the form is posted, do something like $whois = ez(stripslashes(trim( $_POST['domain'] ))); and then you got the stuff you want ez ... enjoy ...
     
    krakjoe, Jan 11, 2007 IP
  7. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks!
    I am trying to keep this clean, so could anyone give me a hint as to how to make a single whois query page.
    I will get all the whois servers for the extensions I need.
    Then I will pay someone to make a clean file that proccess $domain.$extension, and runs it against the list of whois servers and then parses the expiry and the registrar
     
    bobby9101, Jan 12, 2007 IP
  8. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #8
    Barti1987, Jan 12, 2007 IP
  9. kohashi

    kohashi Well-Known Member

    Messages:
    1,198
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    140
    #9
    you could also connect to a registrar's API to query (just another option)
     
    kohashi, Jan 12, 2007 IP