-1

What I am trying to do is download a file from a url like this: http://www.example.com/down/files/425/document-preview?

When I visit this url in my browser, it triggers a file called for example: 425.doc this can be a pdf, rtf, txt, docx etc. file format.

wget is currently saving this file as: document-preview? is there anyway to save it as the file download that is triggered by the url?

This is what I am doing so far:

wget --save-cookies cookies.txt --post-data '[email protected]&js_password=123456789' --keep-session-cookies parameter -p http://www.test.co.za/test/login

wget --load-cookies cookies.txt -p www.test.co.za/downloads/doc/425399/doc-preview? --keep-session-cookies

I want to change the values in a loop of the 425399 for example: from 425399 to 525399 it logs in perfectly and downloads, just want to capture filename and save it as that filename instead of doc-preview? which does not save the right file name which should be: 425399.doc

I did get this example online to do the batch download: wget www.whatever.com/folder/{1..30}.html

but my problem is the file name

2

2 Answers 2

1

use -O option will save files as the specified name

for i in {425399..525399}
do
        wget -O $i.doc --load-cookies cookies.txt -p www.test.co.za/downloads/doc/$i/doc-preview? --keep-session-cookies
done
0

The complete solution to the problem as stated above.

wget --save-cookies cookies.txt --post-data '[email protected]&password=1234' --keep-session-cookies http://www.example.com/login.php

wget --load-cookies cookies.txt -p http://www.example.com/download.php?file_id=file_{1..5000} --content-disposition --directory-prefix=downloads

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