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.

53 lines
1.3 KiB

  1. <?php
  2. // Go Get a Roomie!
  3. // Another ComicPress one, still updating regularly.
  4. $html = file_get_contents('https://www.gogetaroomie.com/');
  5. preg_match('@/comics/(.+\\.(jpg|png|gif))@', $html, $matches);
  6. if (empty($matches[1])) {
  7. echo "No comic found on home page! :(\n";
  8. return;
  9. }
  10. if (!is_dir('gogetaroomie')) {
  11. mkdir('gogetaroomie');
  12. }
  13. // Download current page's comic, load previous comic webpage, repeat
  14. while (true) {
  15. if (is_file('gogetaroomie/' . $matches[1])) {
  16. return;
  17. }
  18. echo "Downloading {$matches[1]}\n";
  19. $url = "https://www.gogetaroomie.com/comics/{$matches[1]}";
  20. $data = @file_get_contents($url);
  21. if ($data) {
  22. file_put_contents("gogetaroomie/{$matches[1]}", $data);
  23. }
  24. // Find previous page link
  25. $regex = '@rel="prev" href="(https://www.gogetaroomie.com/comic/[0-9a-zA-Z-]+)"@';
  26. preg_match($regex, $html, $prevMatch);
  27. if (empty($prevMatch[1])) {
  28. echo "No previous URL found!\n";
  29. return;
  30. }
  31. $html = @file_get_contents($prevMatch[1]);
  32. if (!$html) {
  33. echo "Failed to load previous page!\n";
  34. return;
  35. }
  36. preg_match('@/comics/(.+\\.(jpg|png|gif))@', $html, $matches);
  37. if (empty($matches[1])) {
  38. echo "No image found on page!\n";
  39. return;
  40. }
  41. usleep(5e5);
  42. }