Jump to content

Recommended Posts

Hi

Any idea how I can use curl/snoopy to download file from Javascript based submit button?The file name in url http://localhost:8080/test/test_20090319.zip changes every day.

 

Here is the form page(test.jsp) and LiveHTTPHeader output. 

 

<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>

 

----------------

 

 

====================================

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

 

Link to comment
https://forums.phpfreaks.com/topic/152288-curl-and-javascript/
Share on other sites

if you use the code tags around your php or even html snippets, you will likely get more help

[ code ]Like this but without the spaces in the tags[ /code ]

would be

Like this but without the spaces in the tags

 

How do you plan on finding out what the filename is everyday?

Link to comment
https://forums.phpfreaks.com/topic/152288-curl-and-javascript/#findComment-799735
Share on other sites

I was hoping by being able to invoke the javascript:poponload using curl I don't need to specify the exact file name.(or is it too wishfull ?)

The file name always ends with _YYYYMMDD.zip .

 

Reposting:

Hi

Any idea how I can use curl/snoopy to download file from Javascript based submit button?The file name in url http://localhost:8080/test/test_20090319.zip changes every day.

 

Here is the form page(test.jsp) and LiveHTTPHeader output.

 


<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>

LiveHTTPHeader output.

  
====================================
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 

Link to comment
https://forums.phpfreaks.com/topic/152288-curl-and-javascript/#findComment-799828
Share on other sites

So you need to pull out a filename from a webpage and The file name always ends with _YYYYMMDD.zip

 

how about an over complicated untested script

<?php
$DATA= <<<DATA

<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>
DATA;

if (preg_match('/\'([^\']*?(?:19|20)[0-9]{2}(?:0[1-9]|1[012])(?:0[1-9]|[12][0-9]|3[01])\.zip)\'/i', $DATA, $regs)) {
$result = $regs[1];
}

echo $result;
?>

Link to comment
https://forums.phpfreaks.com/topic/152288-curl-and-javascript/#findComment-799831
Share on other sites

Thanks.

My bad, I should have provided more details.

What I'm really trying to do is creating a shell job which everyday downloads the zip file from a site. The path to the file (http://localhost:8080/test/test_20090319.zip) is actually created on the fly by javascript when the user presses the download button. So the the content of the page does not contain the file path/name .

I guess my question is how I can have curl call the javascript to download the file ?

 

Ross

Link to comment
https://forums.phpfreaks.com/topic/152288-curl-and-javascript/#findComment-799970
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.