I'm trying to download all files from this web page : https://www.lezioni4all.com/ase/appunti So I'm using "wget" command, it didn't work so I did some researches and I found that on the web page above (when I click on the resource that I want to visualise) it opens the document in a new web page and the path is something like : http//something/resource/%10hi%10Ineedof%10thisresource

(If you open the link above and choose one of the elements in the page, for example "conflitti", you will see that there is a kind of "preview" of the item and then when you click on the bottom row the resource will be opened on a new window with the same title that you visualise on the main page but with some percentage like %10,%20... in the name).

Do you know how I could download files that can't be downloaded just putting the url of the page where they are posted?

I already tried these commands :

wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off --no-parent -P ~/Desktop/ASE_lezioni4all https://www.lezioni4all.com/ase/appunti

wget --page-requisites -p --convert-links  -P ~/Desktop/ASE_lezioni4all https://www.lezioni4all.com/ase/appunti

And other, I receive only blank files that open a white window on the internet.

1 Answer 1


The PDF URLs are embedded in javascript onclick attributes. You can grep those:

wget -qO- https://www.lezioni4all.com/ase/appunti | 
  grep -o "https://www\.lezioni4all\.com/files/[^']*\.pdf"

You can download them using the no-clobber option -nc (since every document is linked twice) and -i:

wget -nc -P ~/Desktop/ASE_lezioni4all -i <(
  wget -qO- https://www.lezioni4all.com/ase/appunti |
  grep -o "https://www\.lezioni4all\.com/files/[^']*\.pdf")
  • Very good work! I didn't know it was an onclick property, thanks!
    – feded
    Jan 22, 2021 at 14:46
  • I was changing some lines of code, I have a question for you : I didn't see the path to "files" in the web page. Which is its meaning and why you used it? ( I mean in this line : grep -o "www\.lezioni4all\.com/files/[^']*\.pdf"). )
    – feded
    Jan 22, 2021 at 15:00
  • The onclick attribute looks like this onclick="flightbox('https://www.lezioni4all.com/files/ASE/Appunti/Appunti%20Teoria.pdf?...' and a shorter regex like https://[^']*\.pdf seems to work as well. But since all download files are somewhere under https://www.lezioni4all.com/files/ I used that as base for the regex.
    – Freddy
    Jan 22, 2021 at 15:21
  • But will this work for most of the sites ? I mean to write http...com/files to find the right page with all documents inside?
    – feded
    Jan 22, 2021 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .