Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $urls = get_all_content();
- $uniqueUrls = [];
- foreach ($urls as $url){
- #some of the urls are .json files. we want to skip those
- if (!preg_match("/\.json$/", $url)) {
- echo "$url\n";
- foreach(find_cdn_images($url) as $tmpUrl){
- $uniqueUrls[] = $tmpUrl;
- }
- }
- }
- $fp = fopen('data.txt', 'a');//opens file in append mode.
- foreach(array_unique($uniqueUrls) as $tmpUrl){
- fwrite($fp, "$tmpUrl\n");
- }
- fclose($fp);
- /*
- foreach(array_unique($uniqueUrls) as $tmpUrl){
- shell_exec("wget \"$tmpUrl\"");
- }
- */
- function get_all_content(){
- $data = json_decode(file_get_contents("https://www.northernquest.com/rebuild-cache.json"), true);
- return array_unique($data);
- }
- function find_cdn_images($url){
- $imageUrls = [];
- $html = file_get_contents($url);
- preg_match_all("/src=\"(https:\/\/78fbf27087a4dfa6b5bd-a5ec6c2236045063e04d541df309bb74.ssl.cf2.rackcdn.com\/[^\"]*)\"/", $html, $matches);
- $imageUrls = array_merge($imageUrls, $matches[1]);
- preg_match_all("/background-image: url\(([^\)]*)\)/", $html, $matches);
- $imageUrls = array_merge($imageUrls, $matches[1]);
- return array_unique($imageUrls);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement