I believe the mark up of the page is part of the issue I am having, so I think I need to post the source and a JSFiddle JSFiddle and the orginal GIS page
I am trying to get info such as Name: and Address: from the table at the bottom.
attempt at a solution:
I wrote the following code hoping to see all the table data, yet the table I'm looking to get data from returns nothing.
<?php
$k=0;
$num=1000;
var_dump(libxml_use_internal_errors(true));
$domOb = new DOMDocument();
$html = @$domOb->loadHTMLFile('http://www.gis.catawba.nc.us/website/Parcel/parcel_main.asp?Cmd=query&key=372215634301&type=P');
$domOb->preserveWhiteSpace = false;
$items = $domOb->getElementsByTagName('td');
while ($k<(int)$num){
echo $items->item($k++)->nodeValue.'<br>';
};
?>
all that returned was:
bool(false) Real Estate Search - Legacy Map Layers visible FAQ's Help GIS Home
So I'm hoping someone can tell me what I'm doing wrong to miss all the data I'm looking for? How can I pull just the name and address as easily/simply as possible?
attempted the following as well using Xpath but get lots of warning...
$dom = new DOMDocument;
$dom->load('http://www.gis.catawba.nc.us/website/Parcel/parcel_main.asp?Cmd=query&key=372215634301&type=P');
$s = simplexml_import_dom($dom);
echo $name = $s->xpath('//table[@class="words13]/td[contains(text(), "Name:")]');
echo $add = $s->xpath('//table[@class="words13]/td[contains(text(), Address:)]');
Using the code by user2518542 and combined with hakre code i get the following
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.gis.catawba.nc.us/website/Parcel/parcel_main.asp?Cmd=QUERY&key=372215634301&type=P&width=1280&height=923");
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
$doc->loadHTML($result);
$tds = $doc->getElementsByTagname('td');
foreach($tds as $td) {
printf(" * %s\n", $td->textContent);
echo '<br>';
}
The following successfully prints out all the tags.