Or use a browser add-on that records the traffic.
Or use a protocol analyser such as Wireshark.

On 30/04/2010, Christophe Marchand <[email protected]> wrote:
> 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",
> >
> "/wEPDwUJMTMxNTMwMTE1D2QWAmYPZBYCAgMPZBYEAgEPZBYkAgMPPCsADQEMFCsABQUPMDowLDA6MSwwOjIsMDozFCsAAhYEHgRUZXh0BQVCb2xhZx4ISW1hZ2VVcmwFLH4vUGFnZVRlbXBsYXRlcy9pbWFnZXMvRklfR3JlZW4tZG90LTEwcHg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kb3B0RXhwb3J0BRRjdGwwMCRtYWluJG9wdFNjcmVlbgUXY3RsMDAkbWFpbiRJbWFnZUJ1dHRvbjEFFGN0bDAwJG1haW4kR3JpZFZpZXcxD2dkklF4trRBFw6yMlWuT6mgCtqFIVs="));
> >    // 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:
> [email protected]
>  For additional commands, e-mail:
> [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to