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.

55 lines
1.3 KiB

  1. <?php
  2. // Camp Weedonwantcha
  3. // A fairly simple ComicPress strip, currently on extended hiatus, but
  4. // potentially updating again. We'll start with the current strip and work back
  5. // to the beginning.
  6. $html = file_get_contents('http://campcomic.com/comic');
  7. $path = 'http://hw1.pa-cdn.com/camp/assets/img/katie/comics/';
  8. preg_match('@/katie/comics/(.+\\.(jpg|png|gif))@', $html, $matches);
  9. if (empty($matches[1])) {
  10. echo "No comic found on home page! :(\n";
  11. return;
  12. }
  13. if (!is_dir('campcomic')) {
  14. mkdir('campcomic');
  15. }
  16. while (true) {
  17. if (is_file('campcomic/' . $matches[1])) {
  18. return;
  19. }
  20. echo "Downloading {$matches[1]}\n";
  21. $data = @file_get_contents($path . $matches[1]);
  22. if ($data) {
  23. file_put_contents("campcomic/{$matches[1]}", $data);
  24. }
  25. // Find previous page link
  26. $regex = '@class="btn btnPrev" href="(http://campcomic.com/comic/[0-9a-zA-Z-]+)"@';
  27. preg_match($regex, $html, $prevMatch);
  28. if (empty($prevMatch[1])) {
  29. echo "No previous URL found!\n";
  30. return;
  31. }
  32. $html = @file_get_contents($prevMatch[1]);
  33. if (!$html) {
  34. echo "Failed to load previous page!\n";
  35. return;
  36. }
  37. preg_match('@/katie/comics/(.+\\.(jpg|png|gif))@', $html, $matches);
  38. if (empty($matches[1])) {
  39. echo "No image found on page!\n";
  40. return;
  41. }
  42. usleep(5e5);
  43. }