Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Last active November 14, 2017 18:37
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save hasinhayder/208f84e8a7a80e756536 to your computer and use it in GitHub Desktop.
Save hasinhayder/208f84e8a7a80e756536 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);
@staritsoft
Copy link

Nice ;) (y)

@rafpro
Copy link

rafpro commented Nov 14, 2014

L8: mkdir ($dir); is giving error when there is a existing directory already there in place. I think if we do

if ( ! is_dir($dir) ) {
  mkdir( $dir );
}

it won't show any error then.

@mayeenulislam
Copy link

যদি অ্যাভাডা টেমপ্লেটটা ধরে নিই, এবং প্রথম ফাইলটার পাথ যদি https://0.s3.envato.com/files/62386858/Screenshots/01_home_v1.__thumbnail.jpg হয়, তাহলে usage কীরকম হবে?
১. php envato-screenshots-downloader.php C:\Screenshots\ https://0.s3.envato.com/files/62386858/Screenshots/01_home_v1.__thumbnail.jpg
নাকি
২. php envato-screenshots-downloader.php C:\Screenshots\ https://0.s3.envato.com/files/62386858/Screenshots/
আমি Windows 7-এর PowerShell ব্যবহার করে চেষ্টা করছি, এবং উভয় ক্ষেত্রেই ফলাফল শূণ্য পেয়েছি। :(

@LeopoldJobs
Copy link

No working for me !
Can you explain how to use ?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment