sql:
CREATE TABLE `images` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `domain` varchar(100) NOT NULL, `img_url` varchar(1024) NOT NULL, `img_url_sha1` char(40) NOT NULL, `image` longblob NOT NULL, `added_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `img_url_sha1` (`img_url_sha1`), KEY `domain` (`domain`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Run script as cli:
php cli.php --domain=www.domain.com
#it will save all images from site without any limitsphp cli.php --domain=www.domain.com --maxIterations=50
#you can limit iterations count (count http-queries to unique internal pages)php cli.php --domain=www.domain.com --maxImages=100
#you can limit images count
Plugins should implement ImageSaver_PluginInterface.
Example:
$imageSaver = new ImageSaver_Parser(); $imageSaver->setLog(new Logger_ConsoleLog()); $imageSaver ->registerPlugin(new Plugin_Name()) ->parse($domain);
TODO:
- Учитывать, что ссылки страницы могут строиться относительно <base href="">, если такой тег задан в head страницы;
- Приводить строки к utf8 перед работой с DOMDocument либо использовать регулярки.