Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list = document.querySelectorAll(".title > h5 > .part-link");
- authors = document.querySelectorAll(".details > .author");
- if (list.length != authors.length) {
- error("list author mismatch");
- } else {
- dump = "";
- for (let i=0; i < list.length; i++) {
- let id = list[i].href.match(/\/([0-9A-F]{32})/)[1];
- let name = list[i].href.match(/\/([^/]*)\/[0-9A-F]{32}/)[1];
- let author = authors[i].innerText.replace(/[^a-z0-9]/gi, '-').toLowerCase();
- let tmp = authors[i].parentElement.querySelector(".source > a.url")
- let filename;
- if (tmp) {
- let book = tmp.href.match(/\/([0-9A-F]{32})/)[1];
- filename = `${name}_${author}_(book-${book})`;
- } else {
- filename = `${name}_${author}`;
- }
- let curlQuery = `curl "https://www.cambridge.org/core/services/online-view/get/${id}" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0" -H "Accept: */*" -H "Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3" --compressed -H "X-Requested-With: XMLHttpRequest" -H "Connection: keep-alive" -H "Referer: https://www.cambridge.org/core/books/mathematics-for-machine-learning/when-models-meet-data/${id}" -H "DNT: 1" -H "Pragma: no-cache" -H "Cache-Control: no-cache" -H "TE: Trailers" > "${filename}.html"`;
- dump += curlQuery + "\n";
- }
- console.log(dump);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement