Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save juyal-ahmed/e0d6329ae7c7e3532bae2996a3cdb0d8 to your computer and use it in GitHub Desktop.
Save juyal-ahmed/e0d6329ae7c7e3532bae2996a3cdb0d8 to your computer and use it in GitHub Desktop.
Download large preview images from the envato item's screenshots page
#!/usr/bin/env php
<?php
//usage: php envato-screenshots-downloader.php /path/to/save/screenshots http://url/to/screenshots/page
set_time_limit(0);
$dir = $argv[1];
$source = $argv[2];
print_r($argv);
mkdir ($dir);
$src = file_get_contents($source);
$pattern = '/src="(https:\/\/0.s3[a-zA-Z0-9_\-\.\/%]+)"/i';
preg_match_all($pattern, $src, $matches);
foreach($matches[1] as $url){
$url = str_replace(".__thumbnail","",$url);
$url = str_replace("https","http",$url);
$filename = basename($url);
file_put_contents("{$dir}/{$filename}", file_get_contents($url));
echo "Done {$url}\n";
}
file_put_contents("{$dir}/source.txt",$source);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment