Skip to content

Instantly share code, notes, and snippets.

@AstroCB
Last active June 4, 2020 08:02
Show Gist options
  • Save AstroCB/fc32d604080a63d89d19a208ff55f659 to your computer and use it in GitHub Desktop.
Save AstroCB/fc32d604080a63d89d19a208ff55f659 to your computer and use it in GitHub Desktop.
Scrapes public book pages and converts them to PDF.
var web = require("webpage"),
numPages = 819;
function load(pageNum) {
var url = "https://mediaserver.123library.org/9781292152578/svg/" + pageNum + "/206298/1485375389/907fbc6e4ef67c6e160a3d198b836551/";
var page = web.create();
page.open(url, function(status) {
if (status === "success") {
console.log("Writing page " + pageNum);
page.render("Pages/" + pageNum + ".pdf");
page.close();
} else {
console.log("Page " + pageNum + " failed");
}
});
}
var p = 1;
var interval = setInterval(function() {
if (p <= numPages) {
load(p);
p++;
} else {
clearInterval(interval);
}
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment