Last active
December 14, 2015 04:13
-
-
Save kaz/1abefd37089e50a103c7 to your computer and use it in GitHub Desktop.
AdventCalendarのスクショを自動的に取ってくるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var page = require("webpage").create(); | |
page.open("http://www.adventar.org/calendars/1183", function(){ | |
page.clipRect = page.evaluate(function(){ | |
return document.querySelector(".mod-calendar").getBoundingClientRect(); | |
}); | |
fs.remove("calendar.png"); | |
page.render("calendar.png"); | |
phantom.exit(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(@file_get_contents("time.log")+3600 < time()){ | |
file_put_contents("time.log", time(), LOCK_EX); | |
system("phantomjs capture.js > /dev/null &"); | |
} | |
header("Content-Type: image/png"); | |
echo(@file_get_contents("calendar.png")); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment