Skip to content

Instantly share code, notes, and snippets.

@kaz
Last active December 14, 2015 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaz/1abefd37089e50a103c7 to your computer and use it in GitHub Desktop.
Save kaz/1abefd37089e50a103c7 to your computer and use it in GitHub Desktop.
AdventCalendarのスクショを自動的に取ってくるやつ
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();
});
<?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