Php Preg_matching

Discussion in 'PHP' started by ttyler333, Mar 17, 2011.

  1. #1
    function domain_age($domain){
      $ch = curl_init("http://www.who.is/whois/".$domain);
    curl_setopt ($ch, CURLOPT_URL, $url);
    		curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    		curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
    		curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    		curl_setopt ($ch, CURLOPT_REFERER, 'http://www.google.com/search?q=best+community+forum');
    		
            $pageout = curl_exec($ch);      
            curl_close($ch);
    		
    preg_match_all("/<a href=\"([^\"]+)\">([^\"]+)<\/a>/",$pageout,$output);	
    		print_r($output);
        return $output;
    }
    PHP:
    So basically i am trying to fetch everything. I tried a few things to fetch links, text... but no luck

    http://www.who.is/whois/domainhelpz.com That is the whois page i am getting the data from but what i am looking for is help fetching
    Registrar: GODADDY.COM, INC.
    Whois Server: whois.godaddy.com
    Referral URL: http://registrar.godaddy.com
    Status: clientDeleteProhibited, clientRenewProhibited, clientTransferProhibited, clientUpdateProhibited
    
    Expiration Date: 2012-03-13
    Creation Date: 2011-03-13
    Last Update Date: 2011-03-13
    
    Name Servers:
        ns15.domaincontrol.com
        ns16.domaincontrol.com
    Code (markup):
    Mainly though i want the creation date, expiration, last update, and the name servers. Check the page out though to preview what it looks like
     
    ttyler333, Mar 17, 2011 IP
  2. awood969

    awood969 Member

    Messages:
    186
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    40
    #2
    Dependant on what your doing I think using a compiled language may be better for this. Using something like C# or C/C++ to retrieve data on this sort of scale.
     
    awood969, Mar 17, 2011 IP
  3. Automagick

    Automagick Greenhorn

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    23
    #3
    You have an error on your regexp.

    preg_match_all("/<a href=\"([^\"]+)\">([^\"]+)<\/a>/",$pageout,$output);

    The red part should be ([^<]+)

    Regards
     
    Automagick, Mar 17, 2011 IP
  4. ttyler333

    ttyler333 Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Thanks automagick, appriciate it :). Regex is just a pain for me.
     
    ttyler333, Mar 17, 2011 IP
  5. dgreenhouse

    dgreenhouse Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    dgreenhouse, Mar 17, 2011 IP