Last active
June 4, 2020 08:02
-
-
Save AstroCB/fc32d604080a63d89d19a208ff55f659 to your computer and use it in GitHub Desktop.
Scrapes public book pages and converts them to PDF.
This file contains hidden or 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 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