Hello all,
I think I know the answer for this question allready, but just as curious I am, I'll ask it anyways.
I'm running a webshop which products come with a csv file. I can import all the objectsng without any trouble, the only thing is that images and thumbnail locations are not exported with the the database dump. (it's never perfect heh) You might say, do it manually then, that's what I did in the first place, but after 200 products and RSI, I gave it up and looked for a better more efficient way to do this.
I have asked my distributer and I can use their images for my own goals without any having copyright problems.
When I look at the location of the images, the url looks like this:
../img/i.php?type=i&file=1250757780.jpg
Does anyone have a idea how this problem can be tackled?
For scraping a website, I found this code:
<?php
function save_image($pageID) {
$base = 'http://www.gistron.com';
//use cURL functions to "open" page
//load $page as source code for target page
//Find catalog/ images on this page
preg_match_all('~catalog/([a-z0-9\.\_\-]+(\.gif|\.png|\.jpe?g))~i', $page, $matches);
/*
$matches[0] => array of image paths (as in source code)
$matches[1] => array of file names
$matches[2] => array of extensions
*/
for($i=0; $i < count($matches[0]); $i++) {
$source = $base . $matches[0][$i];
$tgt = $pageID . $matches[2][$i]; //NEW file name. ID + extension
if(copy($source, $tgt)) $success = true;
else $success = false;
}
return $success; //Rough validation. Only reports last image from source
}
//Download image from each page
for($i=1; $i<=6000; $i++) {
if(!save_image($i)) echo "Error with page $i<br>";
}
?>
For some reason it throws this error: Error with page 1, Error with page 2, etc