From: Ben Aroia Date: 2008-04-10T23:56:07+09:00 Subject: Re: User Agent String Zoltan Dezso wrote: > Hi, > > How about: > > require 'net/http' > user_agent = "you can set this part" > h = Net::HTTP.new('www.example.com', 80) > resp, data = h.get('/index.html', {"User-Agent"=>user_agent}) > > Zaki > > Tom Arra wrote: >> Hey guys, >> >> I want my Ruby script to make a request to a server but I don't want it >> to use just the basic User Agent String. How would I go about giving my >> script a User Agent string to use? I've tried the above with the following: user_agent = 'Ruby Net::HTTP' print "Getting h\n" h = Net::HTTP.new('http://www.google.com', 80) print "getting response\n" resp, data = h.get('/', {"User-Agent"=>user_agent}) print data.body print resp print "should've printed\n" and all it gives me is: SocketError: getaddrinfo: No address associated with nodename method initialize in http.rb at line 560 method open in http.rb at line 560 method connect in http.rb at line 560 method timeout in timeout.rb at line 48 method timeout in timeout.rb at line 76 method connect in http.rb at line 560 method do_start in http.rb at line 553 method start in http.rb at line 542 method request in http.rb at line 1032 method get in http.rb at line 769 at top level in rubyheader.rb at line 12 -- Posted via http://www.ruby-forum.com/.