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.

57 lines
1.5 KiB

  1. <?php
  2. // Sandra and Woo
  3. // Another ComicPress one, still updating regularly
  4. // Note that you can get official downloads of this comic, including
  5. // high-resolution and draft versions by supporting the creators on Patreon!
  6. // https://www.patreon.com/sandraandwoo
  7. $html = file_get_contents('http://www.sandraandwoo.com/');
  8. preg_match('@/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('sandraandwoo')) {
  14. mkdir('sandraandwoo');
  15. }
  16. // Download current page's comic, load previous comic webpage, repeat
  17. while (true) {
  18. if (is_file('sandraandwoo/' . $matches[1])) {
  19. return;
  20. }
  21. echo "Downloading {$matches[1]}\n";
  22. $url = "http://www.sandraandwoo.com/comics/{$matches[1]}";
  23. $data = @file_get_contents($url);
  24. if ($data) {
  25. file_put_contents("sandraandwoo/{$matches[1]}", $data);
  26. }
  27. // Find previous page link
  28. $regex = '@href="(http://www.sandraandwoo.com/[0-9]{4}/[0-9]+/[0-9]+/[0-9a-zA-Z-]+/?)" rel="prev"@';
  29. preg_match($regex, $html, $prevMatch);
  30. if (empty($prevMatch[1])) {
  31. echo "No previous URL found!\n";
  32. return;
  33. }
  34. $html = @file_get_contents($prevMatch[1]);
  35. if (!$html) {
  36. echo "Failed to load previous page!\n";
  37. return;
  38. }
  39. preg_match('@/comics/(.+\\.(jpg|png|gif))@', $html, $matches);
  40. if (empty($matches[1])) {
  41. echo "No image found on page!\n";
  42. return;
  43. }
  44. usleep(5e5);
  45. }