You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

  1. <?php
  2. // League of Super Redundant Heroes
  3. // This one is also running ComicPress, but has a slightly different setup.
  4. // Images are stored directly in /wp-content/uploads/, but so are other things!
  5. // This one can take ~1 hour to run as of early 2019.
  6. // We start with the current day, then click the Previous link until we find
  7. // an image we've already saved before.
  8. $html = file_get_contents('http://superredundant.com/');
  9. preg_match('@<img src="http://superredundant.com/wp-content/uploads/([^"]+\\.(jpg|png|gif))@', $html, $matches);
  10. if (empty($matches[1])) {
  11. echo "No comic found on home page! :(\n";
  12. exit(1);
  13. }
  14. if (!is_dir('superredundant')) {
  15. mkdir('superredundant');
  16. }
  17. // Download current page's comic, load previous comic webpage, repeat
  18. while (true) {
  19. if (is_file('superredundant/' . $matches[1])) {
  20. return;
  21. }
  22. echo "Downloading {$matches[1]}\n";
  23. $url = "http://superredundant.com/wp-content/uploads/{$matches[1]}";
  24. $data = @file_get_contents($url);
  25. if ($data) {
  26. file_put_contents("superredundant/{$matches[1]}", $data);
  27. }
  28. // Find previous page link
  29. $regex = '@href="(http://superredundant.com/[\\?0-9a-zA-Z/=-]+)" class="navi comic-nav-previous navi-prev"@';
  30. preg_match($regex, $html, $prevMatch);
  31. if (empty($prevMatch[1])) {
  32. echo "No previous URL found!\n";
  33. return;
  34. }
  35. $html = @file_get_contents($prevMatch[1]);
  36. if (!$html) {
  37. echo "Failed to load previous page!\n";
  38. return;
  39. }
  40. preg_match('@<img src="http://superredundant.com/wp-content/uploads/([^"]+\\.(jpg|png|gif))@', $html, $matches);
  41. if (empty($matches[1])) {
  42. echo "No image found on page!\n";
  43. return;
  44. }
  45. usleep(5e5);
  46. }