开发者

Easy Ruby http/curl API to program with

I've been using Ruby for quite some time now, however unlike PHP, as far as I know there is not a standard http/Curl (fetching, processing forms) like library that is easy and powerful like PHP's libCuRL binding.

While Net::HTTP is part of the Ruby standa开发者_StackOverflow中文版rd library, I always find that API hard to remember and program with.

Can anyone give suggestions on which http/curl library I should use over Net::HTTP?


Take a look at HTTParty or REST Client.


I would recommend using the Typhoeus gem. It's got a pretty clean API and allows you to make concurrent requests.


I'll second Ryan's recommendation for Typhoeus, and recommend HTTPClient also. Both are very full featured and handle parallel requests easily.

For simple requests it's hard to beat Open-URI for its simplicity:

require 'open-uri'
html = open('http://www.example.com').read

If you're parsing a page it works great with Nokogiri:

require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://www.example.com'))


I wrote a wrapper for the Net:HTTP lib recently, its very very simplistic. I wanted something with a simple API that was easy to use and remember, it's been working well for me:

https://github.com/ctcherry/plain_http

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜