curl-users
RE: curl and Javascript based submit form
Date: Thu, 2 Apr 2009 19:00:29 +0000
Thanks.
But the file name in url http://localhost:8080/test_20090319.zip changes every day so I can not use plain 'curl -O http://localhost:8080/test_20090319.zip' command.
Based on LiveHTTPHeader output, I enabled cookies, set referrer header and user-agent as below but all I get in response is the content of test.jsp .
curl -D headers_and_Cookies -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5" -O -k "http://localhost:8080/test/test.jsp?download=OK"
curl -e http://localhost:8080/test/test.jsp -b headers_and_Cookies -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5" -k "http://localhost:8080/test/test.jsp?download=OK"
Response
=============
<html>
<head>
<title>Untitled</title>
<SCRIPT language="JavaScript1.2">
function poponload()
{
var url='http://localhost:8080/test/test_20090319.zip';
testwindow= window.open (url);
}
</script>
</head>
<body>
<form method="GET" action="test.jsp" onsubmit="javascript:poponload()">
<input type="submit"
name="download"
value="OK"
/>
</form>
</body>
</html>
Ross
> Date: Wed, 1 Apr 2009 20:57:01 -0600
> From: dan_at_coneharvesters.com
> To: curl-users_at_cool.haxx.se
> Subject: Re: curl and Javascript based submit form
>
> On Wed, Apr 01, 2009 at 07:58:40PM +0000, R B wrote:
> > Any idea how I can use curl to download file from Javascript based submit
> > button?
> > Here is the form page(test.jsp) :
> >
> > <html>
> > <head>
> > <title>Untitled</title>
> > <SCRIPT language="JavaScript1.2">
> > function poponload()
> > {
> > var url='http://localhost:8080/test_20090319.zip';
> > testwindow= window.open (url);
> > }
> > </script>
> > </head>
> >
> > <body>
> >
> > <form method="GET" action="test.jsp" onsubmit="javascript:poponload()">
>
> The JavaScript here basically co-opts the form and replaces it with a
> plain GET of the url above. You should be able to download it with a
> plain 'curl -O http://localhost:8080/test_20090319.zip' command. You may
> need to enable cookies, set a referrer header and user-agent if not.
>
> >>> Dan
> --
> http://www.MoveAnnouncer.com The web change of address service
> Let webmasters know that your web site has moved
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html
From: rossbertoloni_at_hotmail.com
To: curl-users_at_cool.haxx.se
Subject: RE: curl and Javascript based submit form
Date: Wed, 1 Apr 2009 23:50:04 +0000
Here is the LiveHTTPHeader output. How can I repeat those actions with curl shell command ?.
====================================
http://localhost:8080/test/test.jsp?download=OK
GET /test/test.jsp?download=OK HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/test/test.jsp
Cookie: JSESSIONID=xb3v6b3lo1qb
HTTP/1.x 200 OK
Date: Wed, 01 Apr 2009 23:47:18 GMT
Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.5.0_04
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 441
=================================================
From: rossbertoloni_at_hotmail.com
To: curl-users_at_cool.haxx.se
Subject: curl and Javascript based submit form
Date: Wed, 1 Apr 2009 19:58:40 +0000
Any idea how I can use curl to download file from Javascript based submit button?
Here is the form page(test.jsp) :
<html>
<head>
<title>Untitled</title>
<SCRIPT language="JavaScript1.2">
function poponload()
{
var url='http://localhost:8080/test/test_20090319.zip';
testwindow= window.open (url);
}
</script>
</head>
<body>
<form method="GET" action="test.jsp" onsubmit="javascript:poponload()">
<input type="submit"
name="download"
value="OK"
/>
</form>
</body>
</html>
Windows Live Messenger makes it easier to stay in touch - learn how!
_________________________________________________________________
Reinvent how you stay in touch with the new Windows Live Messenger.
http://go.microsoft.com/?linkid=9650731
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-04-02