tags:

views:

21

answers:

2

I have a quite simple task:

i need to download file from a web page. In browser, it is done by pressing submit button. Just simple button, press it and you see the pop-up window asking where to save file and so on. Data is sent to server via post method.

I tried POST'ing with curl like: curl -d "foo=bar&....." [URL] but this request returns the page itself, not the file. And I am quite confused about how to get the file, since I dont know it's adress on server and the only way to get it is to press this freaking button.

Please help

A: 

Use Wireshark or a browser plugin that captures the http request sent on submit, then use curl or, for example, PHP's file_get_contents() to emulate the request.

GZipp
A: 

If you use unix-like os system you can use wireshark by simple apply filter "http", or some other software, e.g. tcpdump.

if you under ms windows, fiddler2 is very good tools.

first, use this kind tools get the accurate information about the tracfic.

then analyze the http request, especially the rquest cookies header.

finally, struct your own request by curl.

the foo=bar&..... is only the content of the request. you may also attention the header of the request.

or your can post your url, so that other peoplle can help you analyze the stuff.

snyh