I need to read the content of an HTTP URL. I can break the URL up into
server, port and path and use Net::HTTP to read it, but it seems like there
should be an easier way. I’d really like to pass the URL string to a method
of some class that would return an object from a class that inherits from
IO. Does something like that exist? If not, is there an easier way than
using Net::HTTP?
···
WARNING: All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
If you have Ruby 1.7, try
require “net/http”
require “uri”
content = Net::HTTP.get_print(URI.parse(“Example Domain”))
If not,
require “net/http”
require “uri”
uri = URI.parse(“Example Domain”)
content = Net::HTTP.get(uri.host, uri.request_uri, uri.port)
Read net/http.rb if you would need http auth, redirection or proxy server.
This library includes the documentation of itself.
Or try WebFetcher in RAA.
Gotoken
···
At Tue, 8 Oct 2002 02:33:52 +0900, Volkmann, Mark Mark.Volkmann@AGEDWARDS.com wrote:
I need to read the content of an HTTP URL. I can break the URL up into
server, port and path and use Net::HTTP to read it, but it seems like there
should be an easier way. I’d really like to pass the URL string to a method
of some class that would return an object from a class that inherits from
IO. Does something like that exist? If not, is there an easier way than
using Net::HTTP?
BTW, current Net::HTTP code does not support proxies with authentication
enabled which makes it rather unusable in corporate networks. I’ve sent a
patch to fix it to Matz and he forwarded it to Minero Anoki (net/http.rb
maintainer) but fix still isn’t in CVS.
I’m attaching it here in meantime.
ruby-net-http-alt.patch (5.82 KB)
···
On Tue, Oct 08, 2002 at 03:22:07AM +0900, GOTO Kentaro wrote:
At Tue, 8 Oct 2002 02:33:52 +0900, > Volkmann, Mark Mark.Volkmann@AGEDWARDS.com wrote:
I need to read the content of an HTTP URL. I can break the URL up into
server, port and path and use Net::HTTP to read it, but it seems like there
should be an easier way. I’d really like to pass the URL string to a method
of some class that would return an object from a class that inherits from
IO. Does something like that exist? If not, is there an easier way than
using Net::HTTP?
If you have Ruby 1.7, try
require “net/http”
require “uri”
content = Net::HTTP.get_print(URI.parse(“Example Domain”))
If not,
require “net/http”
require “uri”
uri = URI.parse(“Example Domain”)
content = Net::HTTP.get(uri.host, uri.request_uri, uri.port)
Read net/http.rb if you would need http auth, redirection or proxy server.
This library includes the documentation of itself.
–
/ Alexander Bokovoy
Q: What is the sound of one cat napping?
A: Mu.
Is there a std lib way that works both for 1.6 and 1.7?
Massimiliano
···
On Tue, Oct 08, 2002 at 03:22:07AM +0900, GOTO Kentaro wrote:
IO. Does something like that exist? If not, is there an easier way than
using Net::HTTP?
If you have Ruby 1.7, try
require “net/http”
require “uri”
content = Net::HTTP.get_print(URI.parse(“Example Domain”))
If not,
require “net/http”
require “uri”
uri = URI.parse(“Example Domain”)
content = Net::HTTP.get(uri.host, uri.request_uri, uri.port)
Read net/http.rb if you would need http auth, redirection or proxy server.
This library includes the documentation of itself.
Or try WebFetcher in RAA.