Firefox Download from Command Line

command linedownloadfirefox

I want to download content from a site. Originally, I used curl/wget, however, the page demanded a session cookie + had multiple redirects. The page administrator then told me to use Firefox to download the content. This is of course pretty difficult because I want to call the download from a script.

I figured out that

firefox https://url.to.page.com/download_content

works and the download file dialog appears. So I am almost there. Of course, as I want to call the download from a script I don't want to press the "ok" button but download it instantly. Are there any additional command line settings to surpress the download file dialog in firefox and download the file immediately?

Best Answer

Solved the same problem as follows, using Firefox:

  • Open "Network" tab of "Web Developer" tool: Ctrl-Shift-E
  • Visit the page you want to save (e.g. a photo behind a login)
  • Right click the request and choose 'Copy'->'Copy as cURL'

This will give you a command that has all your cookie credentials e.g.

curl 'https://mysite.test/my-secure-dir/picture1.jpg' \ 
-H 'User-Agent: Mozilla/5.0 ...' \
-H 'Cookie: SESSIONID=abcdef1234567890'

You can modify the URL in the command to fetch whatever you want and run it in your shell.