hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mini Traktor <minitrak...@yahoo.com>
Subject Re: Download a file by going to website and submitting a form
Date Mon, 03 May 2010 08:11:37 GMT
Hm.. I can't find the same values of __VIEWSTATE and __EVENTVALUATION in previous response.

I attach the full output from proximitron, after having done the following steps:

(start at http://insynsok.fi.se/SearchPage.aspx?bolagid=556&fromdate=2009-05-03&tomdate=2010-05-03&reporttype=2&culture=sv-SE)
1. Click at "Exportera data"
2. Click at "SÖK"



________________________________
From: sebb <sebbaz@gmail.com>
To: HttpClient User Discussion <httpclient-users@hc.apache.org>
Sent: Fri, April 30, 2010 5:19:20 PM
Subject: Re: Download a file by going to website and submitting a form

On 30/04/2010, Mini Traktor <minitraktor@yahoo.com> wrote:
> Hi!
>  However, posting the same parameters from HttpClient gives the following response:
>
>  "<html><head><title>Object moved</title></head><body>
>  <h2>Object moved to <a href="/PageTemplates/errorNoSess.aspx?aspxerrorpath=/SearchPage.aspx">here</a>.</h2>
>  </body></html>"
>
>  What can be the problem? I suppose it lies with the __VIEWSTATE and __EVENTVALIDATION
parameters as the values for these seems a bit... strange.
>

These values are likely to vary between requests, so you will have to
extract them from the previous response.

>  Best regards,
>  Mini
>
>
>
>  ________________________________
>  From: Christophe Marchand <christophe.marchand@axyus.com>
>  To: HttpClient User Discussion <mailto:httpclient-users@hc.apache.org>
>  Sent: Fri, April 30, 2010 1:47:12 PM
>  Subject: Re: Download a file by going to website and submitting a form
>
>
>  Put a local proxy that log requests and watch out the parameters that are submitted
to server.
>  Then you will just have to change your parameters values as you need.
>
>  Under windows (sometime...), I use Proxomitron
>
>  Regards,
>  Christophe
>
>  Mini Traktor wrote:
>  > Hi!
>  >
>  > I need to download a file using HttpClient. There is no URL that leads directly
to the file but it can be downloaded manually by following these steps:
>  >
>  > 1. Go to this website:
>  > http://insynsok.fi.se/SearchPage.aspx?bolagid=556&fromdate=2009-04-30&tomdate=2009-04-30&reporttype=2&culture=sv-SE
>  > 2. Select the radio button "Exportera data" in the top-right corner
>  > 3. Click the button "SÖK"
>  >
>  > I suppose that I should do some kind of HTTP POST, but I don't know which parameters
to post. I have tried many different combinations, such as the one below. Do anyone know what
I should do to download the file?
>  >    DefaultHttpClient httpclient =    HttpPost httpost =    List <NameValuePair>
nvps =    nvps.add(
>  >    nvps.add(publicstaticvoidmain(String[] args) throwsException {newDefaultHttpClient();newHttpPost("http://insynsok.fi.se/SearchPage.aspx?bolagid=556&fromdate=2009-04-30&tomdate=2009-04-30&reporttype=2&culture=sv-SE");newArrayList
<NameValuePair>();newBasicNameValuePair("ctl00$main$ResultFormatGroup", "optExport"));newBasicNameValuePair("__EVENTTARGET",
"ctl00$main$optExport"));    // nvps.add(new BasicNameValuePair("__EVENTTARGET", "optExport"));
>  >    // nvps.add(new BasicNameValuePair("__LASTFOCUS", ""))
>  >    // nvps.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
>  >    // nvps.add(new BasicNameValuePair("__VIEWSTATE",
>  >
>  
 "/wEPDwUJMTMxNTMwMTE1D2QWAmYPZBYCAgMPZBYEAgEPZBYkAgMPPCsADQEMFCsABQUPMDowLDA6MSwwOjIsMDozFCsAAhYEHgRUZXh0BQVCb2xhZx4ISW1hZ2VVcmwFLH4vUGFnZVRlbXBsYXRlcy9pbWFnZXMvRklfR3JlZW4tZG90LTEwcHgucG5nZBQrAAIWAh8ABQxJbnN5bnNwZXJzb25kFCsAAhYCHwAFBURhdHVtZBQrAAIWAh8ABRhSZWdpc3RyZXJhZCBpbnN5bnNoYW5kZWxkZAIFDw8WAh8ABRVURUxJQVNPTkVSQSBBQiAoUFVCTClkZAIHDxAPFgQfAAUORXhwb3J0ZXJhIGRhdGEeB0NoZWNrZWRoZGRkZAIJDw8WAh8ABRRPcmdhbmlzYXRpb25zbnVtbWVyOmRkAgsPDxYCHwAFCzU1NjEwMy00MjQ5ZGQCDQ8PFgIfAAUXUmVnaXN0cmVyaW5nIHVwcGjDtnJ0OiBkZAIPDxAPFgQfAmcfAAUPVmlzYSBww6Ugc2vDpHJtZGRkZAIRDw8WAh8ABQVWw6RsamRkAhMPEGQQFQUNVHJhbnNha3Rpb25lchBBa3R1ZWxsdCBpbm5laGF2Ekhpc3Rvcmlza3QgaW5uZWhhdgVJbnN5bhlCZWZhdHRuaW5nc2bDtnLDpG5kcmluZ2FyFQUNVHJhbnNha3Rpb25lcgdJbm5laGF2EUhpc3Rvcmlza3RJbm5laGF2BUluc3luGUJlZmF0dG5pbmdzZsO2csOkbmRyaW5nYXIUKwMFZ2dnZ2cWAQICZAIVDw8WBB8ABQZGciBvIG0eB1Zpc2libGVoZGQCFw8PFgQfAAUKMjAwOS0wNC0zMB8DaGRkAhkPDxYCHwAFBURhdHVtZGQCGw8PFgIfAAUKMjAwOS0wNC0zMGRkAh0PDxYCHwNoZGQCHw8PFgIfAQUofi9QY
>  > WdlVGVtcGxhdGVzL2ltYWdlcy9idXR0b25fc2VhcmNoLmdpZmRkAiEPDxYCHwAFDUbDtnJrbGFyaW5nYXJkZAIlDw8WAh8ABQM1NTZkZAInDw8WAh8ABQVEYXR1bWRkAgIPDxYCHwAFEFRmbiAwOC03ODcgODEgNDRkZBgCBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WBAUUY3RsMDAkbWFpbiRvcHRFeHBvcnQFFGN0bDAwJG1haW4kb3B0RXhwb3J0BRRjdGwwMCRtYWluJG9wdFNjcmVlbgUXY3RsMDAkbWFpbiRJbWFnZUJ1dHRvbjEFFGN0bDAwJG1haW4kR3JpZFZpZXcxD2dkklF4trRBFw6yMlWuT6mgCtqFIVs="));
>  >    // nvps.add(new BasicNameValuePair("ctl00$main$ResultFormatGroup", "optExport"));
>  >    // nvps.add(new BasicNameValuePair("ctl00$main$DropDownList1", "HistorisktInnehav"));
>  >    // nvps.add(new BasicNameValuePair("ctl00$main$tomDate", "2009-04-30"));
>  >    // nvps.add(new BasicNameValuePair("__EVENTVALIDATION", "/wEWDwLHzJQpAu6lkLcMAtW8y+QIAs6Sm9EDAu6poZgCAuCEi9wJAv+XioUFAtipkEECiqGu1QMCoZfPrQECt63T+g8CtrHxygoChfbuvQgC2YHiyQoC/aei9gKbrpw0ozpPrgzd2imI6M4O/LNqOw=="));
>  >    // nvps.add(new BasicNameValuePair("ctl00$main$ImageButton1", "true"));    httpost.setEntity(
>  >    HttpResponse response = httpclient.execute(httpost);
>  >    HttpEntity entity = response.getEntity();    File file =    InputStream instream
= entity.getContent();
>  >    OutputStream outstream =        outstream.write(tmp, 0, l);
>  >    }
>  >    outstream.flush();
>  >    instream.close();
>  >    outstream.close();
>  >    entity.consumeContent();
>  >    httpclient.getConnectionManager().shutdown(); }newUrlEncodedFormEntity(nvps,
HTTP.UTF_8));newFile("somefile.zip");newFileOutputStream(file);    byte[] tmp = newbyte[4096];
   intl;    while((l = instream.read(tmp)) != -1) {
>  >
>  >
>  >
>
>
>
>
>  ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: mailto:mailto:httpclient-users-unsubscribe@hc.apache.org
>  For additional commands, e-mail: mailto:mailto:httpclient-users-help@hc.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


      
Mime
View raw message