3

There is a search page in a form http://example.com/search.php and it sends a search query via POST request. I want to fetch this request via curl command line tool to inspect a POST request.

The HTML form looks like this:

<form action="search.php" method="POST">
   <input type="text" name="search" size=20><br>
   SZ<input type="checkbox" checked name="sz">
   NZ<input type="checkbox" checked name="nz">
   <input type="submit" name="search_term" value="search" >
</form>

How should my curl command look like?

  • Curl is an HTTP client - it makes requests (aka fetching resources). It can't intercept a POST from another client, like your browser, which is what it sounds like you want to do. Or did you mean you want to make this POST request with curl? – ckhan Apr 30 '12 at 4:01
4

As an example, to send a search of "foo" with sz checked and nz unchecked:

curl -d "search_term=search&search=foo&sz=on&nz=off" http://example.com/search.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.