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.

39 lines
1.3 KiB

  1. <?php
  2. // Blaster Nation
  3. // This one has ended, so we can hard-code a few things
  4. // We'll work from start to end, unlike most of the other archives
  5. // I chose to use the main comic page URLs instead of the comic filenames here
  6. // since they're actually sequential that way. Makes it much easier to read.
  7. $start = 'http://www.blasternation.com/comic/1-one-day-in-the-life-of-matthew-palmer';
  8. $end = 'http://www.blasternation.com/comic/516-end';
  9. if (!is_dir('blasternation')) {
  10. mkdir('blasternation');
  11. }
  12. $url = $start;
  13. while ($url != $end) {
  14. $html = file_get_contents($url);
  15. preg_match('@src="http://www.blasternation.com/comics/([0-9a-zA-Z-]+\\.[a-z]{3,4})" id="cc-comic"@', $html, $matches);
  16. if (!empty($matches[1])) {
  17. $name = trim(substr($url, 35), '/');
  18. if (glob("blasternation/{$name}*")) {
  19. return;
  20. }
  21. echo "Downloading {$name}\n";
  22. $data = @file_get_contents('http://www.blasternation.com/comics/' . $matches[1]);
  23. if ($data) {
  24. $ext = pathinfo(parse_url($matches[1])['path'], PATHINFO_EXTENSION);
  25. file_put_contents('blasternation/' . $name . '.' . $ext, $data);
  26. }
  27. }
  28. preg_match('@rel="next" href="(http://www.blasternation.com/comic/[0-9a-zA-Z-]+/?)"@', $html, $matches);
  29. $url = $matches[1];
  30. usleep(5e5);
  31. }