Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.ruby

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2009, 06:29 AM
Juan Medín
Guest
 
Posts: n/a
Default Simple http.get() script fails

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 !
--
Posted via http://www.ruby-forum.com/.

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 12-02-2009, 02:03 PM
Mike Stephens
Guest
 
Posts: n/a
Default Re: Simple http.get() script fails

You could try:

require 'open-uri'
http = open('http:/www.google.com')

http then contains your google page data.
--
Posted via http://www.ruby-forum.com/.

Reply With Quote
  #3 (permalink)  
Old 12-02-2009, 10:54 PM
Nik Z.
Guest
 
Posts: n/a
Default Re: Simple http.get() script fails

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...



On Tue, Dec 1, 2009 at 11:29 PM, Juan Med=EDn <juanmedin@gmail.com> wrote:

> 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/n=

et/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/n=

et/http.rb:560:in
> `open'
>
>
> The script is:
>
> USERAGENT =3D '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 =3D Net::HTTP.new( 'http://www.google.com' )
>
> res =3D http.get( '/', {
> 'User-Agent' =3D> USERAGENT,
> 'Accept' =3D> '*/*',
> 'Accept-Language' =3D> 'en-us,en,q=3D0.5',
> 'accept-encoding' =3D> 'gzip;q=3D1.0,deflate;q=3D0.6,identity;q=3D0.3',
> 'Connection' =3D> 'keep-alive',
> 'Keep-Alive' =3D> '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 !
> --
> Posted via http://www.ruby-forum.com/.
>
>


Reply With Quote
 
Reply

Popular Tags in the Forum
fails, httpget, script, simple

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple greatest common factor script fejky Newsgroup comp.lang.python 2 11-29-2009 10:23 AM
Simple template experiment fails Bert Aerts (rm X) Newsgroup comp.language.c++ 3 09-16-2009 12:51 AM
Script runs manually, but cron fails Bryan Newsgroup comp.lang.python 3 07-27-2009 02:40 PM
Script Parameter from Field d-42 Newsgroup comp.databases.filemaker 10 06-10-2009 09:27 PM
simple test of main signature fails Comp1597@yahoo.co.uk Newsgroup comp.language.c++ 2 04-02-2009 06:41 AM



All times are GMT. The time now is 11:59 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.