divadiva Posted July 17, 2008 Share Posted July 17, 2008 Experts : I am trying to parse this website https://resale.intel.com/Inventory.aspx. Here is the code: <?php include("mainpage.php"); include_once("database.php"); set_time_limit(0); parseData('https://resale.intel.com/Inventory.aspx'); function geCurlContent($link) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $link); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); curl_close($ch); return $content; } function parseData($link) { handlOldData('INTEL'); $content = geCurlContent($link); $content = substr($content, strpos($content, "<table cellspacing=\"2\" cellpadding=\"3\" width=\"100%\" border=\"0\">")); $content = substr($content, 0, strpos($content, "</table>")).'</table>'; $content = str_replace("&", "&", $content); /* PROBLEM AREA*/ $dom = new DOMDocument(); $dom->loadHTML($content); $tables = $dom->getElementsByTagName('table'); print a; print $tables; $rows = $tables->item(3)->getElementsByTagName('tr'); print a3; $i = 0; print a1; foreach ($rows as $row) //for each tr { print a2; $cols = $row->getElementsByTagName('td'); //get columns for the current row if($i > 0 && strlen($cols->item(3)->nodeValue)) //if has at least manufacturer { if(checkExists('INTEL', $cols->item(0)->nodeValue) == 0) { $manufacturer = $cols->item(1)->nodeValue; $query .= "insert into data(WebsiteId, Process,Description, site, onmarket) values"; $query .= "('".trim($cols->item(0)->nodeValue)."' , '".trim($cols->item(1)->nodeValue)."', '".$cols->item(3)->nodeValue."', 'MACQUARIE', 1)"; //print '<br/>'.$query; executeNonQuery($query); } } $i++; } } echo 'Data parsed and saved successfully.'; include("footer.php"); ?> These are the errors that I got: Warning: DOMDocument::loadHTML() [function.DOMDocument-loadHTML]: Unexpected end tag : table in Entity, line: 1 in C:\wamp\www\Scraper1\Intel.php on line 37 a Catchable fatal error: Object of class DOMNodeList could not be converted to string in C:\wamp\www\Scraper1\Intel.php on line 40 But I am unable to debug it. Thanks in advance . Link to comment https://forums.phpfreaks.com/topic/115229-help-needed-for-debugging/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.