cURL and click a button in a website cURL and click a button in a website curl curl

cURL and click a button in a website


Your best bet is to use something like Firebug or the Live HTTP Headers plugin (both are for Firefox) to try actually clicking the button and seeing what is going into the resulting request. Then try to replicate it.

Here's a simple example, though:

a form on a web site:

<form action="http://someUrl.com/somePage.html" method="POST">    <input type="text" name="value1"> <br />    <input type="text" name="value2"> <br />    <input type="submit"></form>

Typing "Some value number one" in the first box, typing "Some value number two" in the second box, and clicking the submit button would generate a request that looks something like

POST /somePage.html HTTP/1.1Host: someUrl.com...//various other POST headers hereContent-Type: application/x-www-form-urlencodedContent-Length: 57value1=Some+value+number+one&value2=Some+value+number+two

which would translate into a cUrl command like

curl -d "value1=Some%20value%20number%20one&value2=Some%20value%20number%20two" http://someUrl.com/somePage.html


cURL doesn't parse a DOM itself. But clicking the button probably just submits a form, which curl can do. But you need to figure it out the details (the exact fields, and any cookies) first.