内置的OpenURI是首先要看的地方。它很简单,并且很好地处理了基础知识。
Typhoeus,我曾多次用于并行进程,效果很好。Github 上提供了文档和代码库。
irb(main):009:0> response = Typhoeus::Request.get("www.example.com")
=> #<Typhoeus::Response:0x007ffbcc067cf8 @code=302, @curl_return_code=0, @curl_error_message="No error", @status_message=nil, @http_version=nil, @headers="HTTP/1.0 302 Found\r\nLocation: http://www.iana.org/domains/example/\r\nServer: BigIP\r\nConnection: close\r\nContent-Length: 0\r\n\r\n", @body="", @time=0.035584, @requested_url=nil, @requested_http_method=nil, @start_time=nil, @start_transfer_time=0.035529, @app_connect_time=2.8e-05, @pretransfer_time=0.000429, @connect_time=2.8e-05, @name_lookup_time=2.8e-05, @request=:method => :get,
:url => www.example.com, @effective_url="HTTP://www.example.com", @primary_ip="192.0.43.10", @redirect_count=0, @mock=false>
irb(main):010:0> puts response.headers
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: close
Content-Length: 0
我偶尔也使用 Net::HTTP,但 OpenURI 和 Typhoeus 与 Hydra 一起被证明易于使用并与我的代码集成。