How to get real file name from wget

I am writing a bash script and using wget to extract some pdf files from a website. For instance:

wget www.barb.co.uk/news/item-subscriber/id/213/index.html 

But wget saves the file as index.html. If I’m in the browser and enter this URL, it will correctly download the file with its real name - "BARB Bulletin 25 - December 10.pdf".

How can I get wget to do the same? Or is there another way to find the real file name (from a bash script)?

+4
source share
2 answers

You can use the --content-disposition option to let wget --content-disposition HTTP response headers more thoroughly, which helps in most cases.

Example:

 wget --content-disposition www.barb.co.uk/news/item-subscriber/id/213/index.html 
+14
source

Take a look at the wgets --content-disposition option.

+3
source

Source: https://habr.com/ru/post/1445492/


All Articles