Created
October 30, 2021 08:32
-
-
Save fernandojsg/c8646b917e10e60f2bae31600eb1411d to your computer and use it in GitHub Desktop.
Libro inglés
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
import img2pdf | |
import os | |
dirname = "." | |
imgs = [] | |
for i in range(143): | |
path = os.path.join(dirname, str(i + 1) + ".jpg") | |
if os.path.isdir(path): | |
continue | |
imgs.append(path) | |
with open("output.pdf","wb") as f: | |
f.write(img2pdf.convert(imgs)) |
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
async function download() { | |
let i = 1 | |
const numImages = 143 | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
let int = setInterval( async function() { | |
if ( i > numImages ) { | |
clearInterval( int ); | |
return; | |
} | |
document.getElementById(`thumbnail-${i}`).click() | |
await sleep(1000) | |
const img = document.querySelector(`li[data-page-number="${i}"] > .fullsize-image`) | |
let a = document.createElement('a'); | |
a.href = img.src; | |
a.download = `${i}.jpg`; | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); | |
i++; | |
}, 500) | |
} | |
download() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment