cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Query string not working using cURL

From: G. T. Stresen-Reuter <tedmasterweb_at_gmail.com>
Date: Thu, 29 Apr 2010 09:10:54 +0100

Hi and welcome to the list!

On Apr 29, 2010, at 1:58 AM, ubuntu serv.user wrote:

> I've read the cURL tutorial (http://curl.haxx.se/docs/httpscripting.html)
>
> When I navigate to the following in a browser:
>
> http://www.kayak.com/s/search/air?do=y&ft=rt&ns=y&cb=e&pa=1&l1=MSP&t1=e&df=us1&d1=05/20/2010&l2=PHX&t2=e&d2=05/23/2010&b=US
>
> I get the results back that I expect.
>
> When I type the below in the terminal window from my computer running Ubuntu Desktop 9.10:
>
> curl -d "do=y&ft=rt&ns=y&cb=e&pa=1&l1=MSP&t1=e&df=us1&d1=05/20/2010&l2=PHX&t2=e&d2=05/23/2010&b=US" http://www.kayak.com/s/search/air
>
> I get the following back (garbage):

From the man page:

       -d/--data <data>
              (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way
              that a browser does when a user has filled in an HTML form and presses the submit
              button. This will cause curl to pass the data to the server using the content-type
              application/x-www-form-urlencoded. Compare to -F/--form.

              -d/--data is the same as --data-ascii. To post data purely binary, you should instead
              use the --data-binary option. To URL-encode the value of a form field you may use
              --data-urlencode.

              If any of these options is used more than once on the same command line, the data
              pieces specified will be merged together with a separating &-symbol. Thus, using '-d
              name=daniel -d skill=lousy' would generate a post chunk that looks like
              'name=daniel&skill=lousy'.

              If you start the data with the letter @, the rest should be a file name to read the
              data from, or - if you want curl to read the data from stdin. The contents of the
              file must already be URL-encoded. Multiple files can also be specified. Posting data
              from a file named 'foobar' would thus be done with --data @foobar.

What that means is that the "form values" of the request are sent to the server using a POST method.

Try just plain-jane curl URL as in:

curl "http://www.kayak.com/s/search/air?do=y&ft=rt&ns=y&cb=e&pa=1&l1=MSP&t1=e&df=us1&d1=05/20/2010&l2=PHX&t2=e&d2=05/23/2010&b=US"

and it should work just fine (just did for me).

Ted Stresen-Reuter

(Finally, a question I'm able to answer!)

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-29