ukscotth Posted July 1, 2011 Share Posted July 1, 2011 Hi all, I've writen a piece of code for a client which basically scarpes data, it works fine on my server but when we upload it to his it displays a blank page Any ideas ? Heres the code : <?php // START OF SITE SCRAPING CODE // Scrape the Data $oldSetting = libxml_use_internal_errors( true ); libxml_clear_errors(); $html = new DOMDocument(); $html->loadHtmlFile( 'http://www.merchandizeliquidators.com/category/10/Bed_and_Bath.html?size=1000'); $xpath = new DOMXPath( $html ); $links = $xpath->query( "//table[@class='thumbnail_item']" ); $return = array(); foreach ( $links as $item ) { $newDom = new DOMDocument; $newDom->appendChild($newDom->importNode($item,true)); $xpath = new DOMXPath( $newDom ); $image_url = trim($xpath->query("//img [@class='thumbnail_image']/@src") ->item(0)->nodeValue); $item_url = trim($xpath ->query("//a[@class='thumbnail_item_name']/@href") ->item(0)->nodeValue); $item_title = trim($xpath ->query("//a[@class='thumbnail_item_name']") ->item(0)->nodeValue); $item_desc = trim($xpath ->query("//div[@class='thumbnail_item_desc']") ->item(0)->nodeValue); $item_price = trim($xpath ->query("//td[@class='price']") ->item(0)->nodeValue); $image_url = 'http://www.merchandizeliquidators.com'.$image_url; $item_url = 'http://www.merchandizeliquidators.com'.$item_url; // Display the Data ?> <table width="450px" border="0" cellpadding="5" align="center"> <tr> <td width="14%" valign="top"> <a href="<?php echo $item_url;?>"><img src="<?php echo $image_url;?>" width="100" height="100" border="0"/></a> </td> <td width="86%" valign="top"> <?php echo '<h2><a href="'.$item_url.'">'.$item_title.'</a></h2>';?> <?php echo '<p>'.$item_desc.'</p>';?> <?php echo '<p>Price: '.$item_price.'</p>';?> <a href="<?php echo $item_url;?>"> <img src="http://cellphoneconnect.co.uk/store/includes/templates/RI_TEMPLATE_07/buttons/english/button_more_info.gif" border ="0"/> </a> <hr /> </tr> </table> <?php } libxml_clear_errors(); libxml_use_internal_errors( $oldSetting ); // END OF SITE SCRAPING CODE ?> Quote Link to comment Share on other sites More sharing options...
wizard32 Posted July 1, 2011 Share Posted July 1, 2011 Maybe the libary is not installed on that server. Put error_reporting(E_ALL); ini_set('display_errors', true); on top of the page and see if you get errors Quote Link to comment Share on other sites More sharing options...
ukscotth Posted July 1, 2011 Author Share Posted July 1, 2011 Thanks wizard. He seems to of vanished at the moment but as soon as hes back Il get him to give it a try. Thanks again. Quote Link to comment Share on other sites More sharing options...
ukscotth Posted July 1, 2011 Author Share Posted July 1, 2011 Ok it came up with this error : Warning: DOMDocument::loadHTMLFile() [function.DOMDocument-loadHTMLFile]: URL file-access is disabled in the server configuration in /var/www/vhosts/merchandizeliquidators.com/httpdocs/scraper.php on line 35 Warning: DOMDocument::loadHTMLFile(http://www.merchandizeliquidators.com/category/10/Bed_and_Bath.html?size=1000) [function.DOMDocument-loadHTMLFile]: failed to open stream: no suitable wrapper could be found in /var/www/vhosts/merchandizeliquidators.com/httpdocs/scraper.php on line 35 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.