cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to click a button on a website using libcurl?

From: WiZaRd <thewizardofdos_at_gmail.com>
Date: Wed, 25 Aug 2010 19:34:32 +0200 (Mitteleuropäische Sommerzeit)

Hello there,

I am using libcurl in a C++ application and I encountered a problem that I
couldn't solve by reading libcurls docs, searching the net and trying around

I want to visit a site that dynamically enables a "Download" button after
some time (similar to a lot of filehosters). After waiting my turn and
re-visiting the site, I get a

> <button type="button" id="download">Download</button>

that I have to click to start the download. The code for that is in the
<script> part:

> function get_link()
> {
> var button_label = $('#download').html();
>
> var r = function(resp)
> {
> $('#ajax_loading').hide();
> $('#download').html('Download');
>
> if(resp && resp.link)
> {
> file_link = resp.link;
> $('!download').onclick = function(){download_file();}
> }
> }
>
> do_request('files', 'get', {action: 'get_link', file_id: 1234, code:
abcd", pass: $('!pass').value}, r);
> }
>
> function download_file()
> {
> if(file_link)
> {
> $('#ajax_loading').show();
> setTimeout(function(){$('#ajax_loading').hide();}, 10000);
> $('!file_form').action = file_link;
> $('!file_form').submit();
> }
> }
>
> get_link();

when retrieving the site, the file_file is

> <form id="file_form"></form>



How can I simulate a "click" onto the "download" button to retrieve the URL
that's needed to download the file?! I managed to handle forms but I fail to
see what URL and parameters to pass to curl_easy_perform.
Thanks in advance and BR,
 Michael

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-25