0

Good day.

For get remote html i use code:

$file = file_get_contents('http://who.is/whois/abate.com');
libxml_use_internal_errors(true); //Prevents Warnings, remove if desired
$dom = new DOMDocument();
$dom->loadHTML($file);

And i get html:

<table>
    <tbody>
        <tr>
    <th>Expires On</th>
    <td><span data-bind-domain="expiration_date" style="visibility: visible;">November 28, 2015</span></td>
    </tr>
            <tr>
    <th>Registered On</th>
    <td><span data-bind-domain="expiration_date" style="visibility: visible;">June 03, 1995</span></td>
    </tr>
            <tr>
    <th>Updated On</th>
    <td><span data-bind-domain="expiration_date" style="visibility: visible;">June 01, 2013</span></td>
    </tr>
        </tbody></table>

I would like get:

1) date Expires On

2) date Registered On

3) date Updated On

Anyone have ideas how make it ?

Alex N
  • 1,111
  • 4
  • 13
  • 20

1 Answers1

2

After the following block of code runs, $values should contain the expiration, registration, and update dates of the domain name:

$xpath = new DOMXPath($dom);
$result = $xpath->evaluate('//table/tbody/tr[th="Expires On" or th="Registered On" or th="Updated On"]/td/span');

$values = array();
foreach($result as $node) {
    $values[] = $node->textContent;
}
array(3) {
  [0]=>
  string(17) "November 28, 2015"
  [1]=>
  string(13) "June 03, 1995"
  [2]=>
  string(13) "June 01, 2013"
}