Jump to content

Scraping code works on one server but not the other.


ukscotth

Recommended Posts

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
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.