/ Published in: Ruby
reference:
\n
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html
\n
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#1 response = http.get(\'/index.html\') # using block File.open(\'result.txt\', \'w\') {|f| http.get(\'/~foo/\') do |str| f.write str end } #2 res = Net::HTTP.get_response(URI.parse(\'http://www.example.com/index.html\')) print res.body #3 res = Net::HTTP.get_response(\'www.example.com\', \'/index.html\') print res.body