Equivalent of cURL for Ruby?

Viewed 76488

Is there a cURL library for Ruby?

12 Answers

If you like it less low-level, there is also Typhoeus, which is built on top of Curl::Multi.

Use OpenURI and

  open("http://...", :http_basic_authentication=>[user, password])

accessing sites/pages/resources that require HTTP authentication.

Curb-fu is a wrapper around Curb which in turn uses libcurl. What does Curb-fu offer over Curb? Just a lot of syntactic sugar - but that can be often what you need.

There's also Mechanize, which is a very high-level web scraping client that uses Nokogiri for HTML parsing.

To state the maybe-too-obvious, tick marks execute shell code in Ruby as well. Provided your Ruby code is running in a shell that has curl:

puts `curl http://www.google.com?q=hello`

or

result = `
  curl -X POST https://www.myurl.com/users \
  -d "name=pat" \
  -d "age=21"
` 
puts result
Related