Forked from hasinhayder/envato-screenshots-downloader.php
Last active
August 29, 2015 14:09
-
-
Save prio101/cb8a59ecccad4b318ed0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#!/usr/bin/env 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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment