Simple http.get() script fails

J

Juan Medín

Hi,

Using a simple test script to get Google's start page HTML gives me the
following error:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:560:in
`initialize': getaddrinfo: nodename nor servname provided, or not known
(SocketError)
from
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:560:in
`open'


The script is:

USERAGENT = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.0.10) ' +
'Gecko/2009042315 Firefox/3.0.10'

http = Net::HTTP.new( 'http://www.google.com' )

res = http.get( '/', {
'User-Agent' => USERAGENT,
'Accept' => '*/*',
'Accept-Language' => 'en-us,en,q=0.5',
'accept-encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Connection' => 'keep-alive',
'Keep-Alive' => '115'
} )

puts res.body


Googling for it shows some results stating the there was an error with
OS X 10.5.3 (I'm using 10.6.2) but I find hard to believe that the error
is still there in such a core library, so the problem must be in my
code.

Can anyone provide some light on this? Thanks !
 
N

Nik Z.

Didn't you forget to put in your PROXY settings?? NodeName not found
normally means you didn't even get out of your own network block...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top