J
Joe Johnson
Here's my little code:
-----------------------------------------------------
#!/usr/bin/ruby -w
require 'socket'
def get_web(url)
puts url
begin
t = TCPSocket.new(url, 80)
rescue
puts "error: #{$!}"
else
t.print "GET / HTTP/1.0\n\n"
answer = t.gets(nil)
t.close
end
puts answer
end
get_web('www.yahoo.com') #1
get_web('www.yahoo.com/r/xn') #2
------------------------------------------------------
Call #1 I get a page back, everything's fine.
Call #2 I get the following erorr:
www.yahoo.com/r/xn
error: getaddrinfo: Name or service not known
nil
I tried different pages that have subdirectories in the url,
they all return me the same error.
So it seems to know whenever my url isn't in the form
of www.site.com, I get the error.
Does anyone know how I can fix the problem? TIA!
JJ
-----------------------------------------------------
#!/usr/bin/ruby -w
require 'socket'
def get_web(url)
puts url
begin
t = TCPSocket.new(url, 80)
rescue
puts "error: #{$!}"
else
t.print "GET / HTTP/1.0\n\n"
answer = t.gets(nil)
t.close
end
puts answer
end
get_web('www.yahoo.com') #1
get_web('www.yahoo.com/r/xn') #2
------------------------------------------------------
Call #1 I get a page back, everything's fine.
Call #2 I get the following erorr:
www.yahoo.com/r/xn
error: getaddrinfo: Name or service not known
nil
I tried different pages that have subdirectories in the url,
they all return me the same error.
So it seems to know whenever my url isn't in the form
of www.site.com, I get the error.
Does anyone know how I can fix the problem? TIA!
JJ