Leone25 / booktab-downloader

A python script to download you Zanichelli books from web Booktab as PDFs
MIT License
41 stars 6 forks source link

errore nel download #30

Closed BayMax-92 closed 1 year ago

BayMax-92 commented 1 year ago

Italian version:

Ciao a tutti. Sono nuovo in github e totalmente ignorante in materia di programmazione, per cui mi scusa in anticipo se non sto usando correttamente questa sezione e se dirò stupidaggini. Vorrei, innanzitutto, ringraziare Leone25 che, con la sua repository, mi ha permesso di scaricare in formato pdf alcuni testi acquistati. In particolare la repository relativa a kitaboo reader non mi ha dato alcun problema, ma questa di booktab si: innanzitutto avevo 3 testi da scaricare (volumi 3,4 e 5 dello stesso testo, di cui volume 3 più recente, seconda edizione e gli altri 2 prima edizione). Lanciando lo script in python mi compare, dapprima, il seguente errore:

(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

che, però, cercando online, sono riuscito a bypassare aggiungendo un verify:False evitando il controllo dei certificati. Il problema è che, così facendo, non ho avuto difficoltà a scaricare il volume 3, il più recente, ma, per gli altri due volumi, mi compare il seguente errore:

PyPDF2.errors.PdfReadError: PDF starts with '{"err', but '%PDF-' expected

Ho provato a sostituire "PyPDF2.PdfFileReader" con "PyPDF2.PdfReader", ma l'unica cosa che ho ottenuto è stata sostituire un errore con un altro, in particolare compare il seguente errore:

PyPDF2.errors.PdfReadError: EOF marker not found

Ho provato a prendere i cookies sia da chrome che da firefox, seguendo le istruzioni, ma niente. L'unica differenza che ho notato è che il volume che riesco a scaricare ha i cookies sotto "spine.xml", mentre i 2 che mi danno errore li hanno sotto "volume.xml". Questa è l'unica differenza che ho trovato, a parte il fatto che quelli che non riesco a scaricare sono una edizione precedente.

Grazie, sin da ora, a quanti sapranno aiutarmi

English version:

Hi everyone. I'm new to github and totally ignorant of coding, so I apologize in advance if I'm not using this section correctly and if I say stupid things. First of all, I would like to thank Leone25 who, with his repository, allowed me to download some purchased texts in pdf format. In particular, the kitaboo reader repository didn't give me any problems, but the booktab one did: first of all I had 3 texts to download (volumes 3, 4 and 5 of the same text, of which volume 3 is more recent, second edition and the others 2 first edition). Running the python script, I first get the following error:

(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

which, however, looking online, I managed to bypass by adding a verify:False avoiding the certificate check. The problem is that, by doing so, I had no difficulty downloading volume 3, the most recent, but, for the other two volumes, I get the following error:

PyPDF2.errors.PdfReadError: PDF starts with '{"err', but '%PDF-' expected

I tried to replace "PyPDF2.PdfFileReader" with "PyPDF2.PdfReader", but the only thing I got was to replace one error with another, in particular the following error appears:

PyPDF2.errors.PdfReadError: EOF marker not found

I tried to get the cookies from both chrome and firefox, following the instructions, but nothing. The only difference I've noticed is that the volume I can download has cookies under "spine.xml", while the 2 that give me errors have them under "volume.xml". That's the only difference I've found, except that the ones I can't download are an older edition.

Thanks, in advance, to those who can help me

Leone25 commented 1 year ago

non so che linguaggio tu preferisca che io usi per rispondere, ma per adesso uso l'italiano, fammi sapere.

Non ti preoccupare, stai facendo i passi corretti, in realtà meglio della media degli utenti.

Per quanto concerne il tuo problema, è strano come errore, quello che pare a me è che per qualunque motivo il libro non è un formato pdf ... mi pare di ricordare che libri più vecchi funzionassero con flash, quindi potrebbe essere qualcosa relativo a ciò. Per provare ti consiglierei di aggiungere print(pdf) dopo la richiesta del file a linea 116, dovrebbero comparirti dei nuovi messaggi nel terminale, potrebbe darci qualche suggerimento.

Fammi sapere

BayMax-92 commented 1 year ago

Ciao Leone25 ! Innanzitutto grazie mille per aver risposto così rapidamente e scusami per non aver fatto altrettanto. Colgo l'occasione anche per ringraziarti per l'altra tua repository relativa a kitaboo. Per me va benissimo continuare in italiano, se per te è lo stesso. Ad ogni modo, ho provato a fare quanto da te detto e spero di aver fatto bene. Ho aggiunto il comando "print(pdf)", ma non è cambiato nulla, stesso identico errore di prima. Il comando l'ho aggiunto immediatamente dopo la linea 116, in questo modo:

pdf = requests.get('https://web-booktab.zanichelli.it/api/v1/resources_web/'+isbn+'/'+part.getAttribute("btbid")+'/'+pdfUrl, verify=False, headers={'Cookie':cookie})

print(pdf)
Leone25 commented 1 year ago

Hmmm, strano

Senti, scrivimi in privato su twitter (stesso nome + 03) così posso aiutarti meglio