Curl to download a file from website

Hello
I have file that I need to download for reports to turn in.
How can I use curl or wget to download the file that I have to click on the "download" button?

Below is a wget from the  HTML page that shows the "download" button in code.

<p>File is too large to display (36247KB).  To view the file, download it to a local hard drive and open it in a text editor.</p>
<table>
<form action='/cgi-bin/repot.cgi/da/reporting_mail_detailed.html'>
<input type='hidden' name='pr_op' value='dump'>
<input type='hidden' name='sessionid' value='AAaaaasdsds'>
<input type='hidden' name='repo_yearday' value='2011-350'>

<tr><td>
<font class=text1>&nbsp;<input type='submit' name='exportnow' value='Download' class='btn'></font>
</td></tr>
</form>

Open in new window

LVL 1
mechanicus01Asked:
Who is Participating?
 
mechanicus01Author Commented:
Ok, I found the answer at http://curl.haxx.se/docs/httpscripting.html


4.1 GET
 
  A GET-form uses the method GET, as specified in HTML like:
 
        <form method="GET" action="junk.cgi">
          <input type=text name="birthyear">
          <input type=submit name=press value="OK">
        </form>
 
  In your favorite browser, this form will appear with a text box to fill in
  and a press-button labeled "OK". If you fill in '1905' and press the OK
  button, your browser will then create a new URL to get for you. The URL will
  get "junk.cgi?birthyear=1905&press=OK" appended to the path part of the
  previous URL.
 
  If the original form was seen on the page "www.hotmail.com/when/birth.html",
  the second page you'll get will become
  "www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK".
 
  Most search engines work this way.
 
  To make curl do the GET form post for you, just enter the expected created
  URL:
 
        curl "http://www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK"
 

0
 
arober11Commented:
If your using:

Firefox, download and install the LiveHTTPHeader plug-in, enable from the Tools menu and download the file, then have a look in the log for the files URL.

Chrome - Press F12 on the page and select the "Network" tab, and download the tile.
0
 
mechanicus01Author Commented:
Ok, I'm on Chrome > Network and the request method is GET but I don't see how to download the file.
Plus , I would like to use some CLI method because I need to script the download.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
mechanicus01Author Commented:
Unless there is a different way to download the file from a Unix script
0
 
arober11Commented:
When you download the File (click the "save as"), a header / network object should appear in the history with the absolute URL to the file. Cut'n'paste this into your curl script.
0
 
mechanicus01Author Commented:
Didn't work for me. Do you have a screenshot of what I should be looking for?
0
 
mechanicus01Author Commented:
Any news?
0
 
Ray PaseurCommented:
I got a neglected question alert on this.  Have you tried just clicking the Download button?  It looks like it might take a while over HTTP if you have to download 35 megabytes, but my sense is that you want to ride this horse in the direction it is already going.
0
 
mechanicus01Author Commented:
Of course I've tried to click the download button via the GUI but that is not what I need.
I need to download the file through a wget, cURL, or other.
0
 
Ray PaseurCommented:
What programming languages do you have available to you?
0
 
Ray PaseurCommented:
Also, what is the URL of the page that has the HTML posted above?
0
 
mechanicus01Author Commented:
Although I am not, I see that you handle php well, so we can try that language.
The URL is a server where the file is is in a LAN so your can't get to it. What exactly do you need to know?
0
 
mechanicus01Author Commented:
What I am trying to do is script the download using AppleScript or a Shell script then schedule a cron job to download it at 10 mins past midnight.
0
 
mechanicus01Author Commented:
First time I answer my question here at EE :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.