From: Joseph Pecoraro Date: 2008-01-28T13:42:11+09:00 Subject: Re: Extracting Data from a Webpage 7stud -- wrote: > Nice. I tested your code and it works for me. But my reading of the > docs says that it shouldn't work: new() doesn't open a connection, and > get(), "Gets data from path on the connected-to host." The docs seem > to want you to do something like: > > resp_obj = Net::HTTP.get_response('http://www.google.com', > '/index.html') > page = resp_obj.body Reading the Net::HTTP docs here: http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M001127 It says that Net::HTTP#get will: "Send a GET request to the target and return the response as a string" and Net::HTTP#get_response will: "Send a GET request to the target and return the response as a Net::HTTPResponse object" The #new in this case is optional because both methods are class methods or instance methods? Someone might be able to clarify this a part a little more. But the examples at that doc url don't even use New::HTTP#new. -- Posted via http://www.ruby-forum.com/.