2

I am developing a whois app for my self to maintain expiry dates of my country level domains (PK). Our PKNIC provider doesn't allow any API or XML to get any such data so i googled found this code that could work now i need a little more code to retrieve only expiry date into a text box.

<?php
$postdata = http_build_query(
array(
    'name' => 'google.com.pk',
)
);

$opts = array('http' =>
array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
)
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://pk5.pknic.net.pk/pk5/lookup.PK', false, $context);
//print_r($result);
echo $result;
?>

Using the above code i get the results something like this..

  <tr>
      <td>&nbsp;</td>
    <td background="img/bg_diagnol.gif"><div align="right" class="style2">Create Date:</div></td>
    <td>&nbsp;</td>
    <td background="img/square.gif"><span xclass="TD_small">2003-03-05</span></td>
  </tr>
    <tr>
      <td>&nbsp;</td>
    <td background="img/bg_diagnol.gif"><div align="right" class="style2">Expire Date: </div></td>
    <td>&nbsp;</td>
    <td background="img/square.gif">2013-03-05</td>
  </tr>
    <tr>
      <td>&nbsp;</td>
    <td background="img/bg_diagnol.gif">&nbsp;</td>
    <td>&nbsp;</td>
    <td background="img/square.gif">&nbsp;</td>
  </tr>
    <tr>
      <td>&nbsp;</td>
    <td background="img/bg_diagnol.gif"><div align="right" class="style2">Agent Organization:</div></td>
    <td>&nbsp;</td>
          <td background="img/square.gif">MarkMonitor       <!--
     &nbsp; &nbsp; <span class="footer"></span> 
     -->
        </td>

Now i just want to retrieve the Domain Expiry Date, is it possible ? Something maybe like

$('td').find('Expire Date:').after().html

Or is there any regx i can search for date format and copy into text box ?

4

1 回答 1

1

This seems like weirdly formatted xml to return (looks like it's more for display than consumption), but you can still do it. .after is for DOM manipulation.

$(":contains(Expire Date)").parent().next().next().html();
于 2013-01-27T14:33:35.377 回答