7
7stud --
The following is from "Programming Ruby 2nd" p.133:
----
require "net/http"
h = Net::HTTP.new("www.programaticprogrammer.com", 80)
response = h.get("/index.html")
if response.message == "OK"
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
----
It doesn't work: nothing is printed. So, I modified it a little:
-----
require "net/http"
h = Net::HTTP.new("www.programaticprogrammer.com", 80)
response = h.get("/index.html")
puts response.message
puts response.code
if response.message == "OK"
puts "*"
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
-----
and the output was:
Found
302
I clicked a link on their home page and tried to access the page that
was displayed, but I got the same result. What am I doing wrong?
----
require "net/http"
h = Net::HTTP.new("www.programaticprogrammer.com", 80)
response = h.get("/index.html")
if response.message == "OK"
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
----
It doesn't work: nothing is printed. So, I modified it a little:
-----
require "net/http"
h = Net::HTTP.new("www.programaticprogrammer.com", 80)
response = h.get("/index.html")
puts response.message
puts response.code
if response.message == "OK"
puts "*"
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
-----
and the output was:
Found
302
I clicked a link on their home page and tried to access the page that
was displayed, but I got the same result. What am I doing wrong?