-   Programming (
-   -   Using curl to post data in a bash script rather than use a web page. (

pobrika 06-07-2012 05:42 PM

Using curl to post data in a bash script rather than use a web page.

I am trying to find a way in a bash script to POST data and get the results back from a web page, so I can automate the process.

I understand curl is probably the tool for the job however I can not get the syntax correct.

Using the web developer program in firefox I have found the following the code that is executed from the web page when manually entering a UK town name on the following broadband checking page.


<form method="POST" action="/broadband/exchange_search" id="exchangesearch-form">
<ul class="error_list">

And also this code is used.


<input maxlength="60" type="text" name="exchange_search[exchange]" id="exchange-input" /> <button id="submit-exchangesearch">Search</button>
I have tried the following curl command but am unsuccessful in getting results.

curl --request POST '' --data "exchange-input=HARLESDEN"
Please can someone show me how this could work, I have read various information on curl but I am having no luck so far.


bigearsbilly 06-07-2012 05:50 PM

your command works for me.

Also wget can do this.

pobrika 06-08-2012 03:18 AM


Although I am not getting any errors with the command I do not seem to be getting the results from the POST, I expected to see the HARLESDON and exchange name returned in the results.

Can anyone see or advise what I am doing incorrectly.


pobrika 06-08-2012 03:32 AM

I have managed to get it working, seems I was not using the correct field ID in my statement.
the following code finds the Town and prints the Exchange name.


curl -s --request POST '' --data 'exchange_search[exchange]=HARLESDEN'| grep -i Harlesden | cut -d"/" -f4| cut -d"\"" -f1

All times are GMT -5. The time now is 10:42 AM.