Hi,
I am working on a web tool that takes user input and submits this
information to a list of websites like google, yahoo, hotmail etc. It
automates form (e.g login form) submission for these websites using
Mechanize in Ruby.
I have used eruby for the web pages, but when I try to use Mechanize,
the
web page gives error “Temporary failure in name resolution”
<%
require ‘rubygems’
require ‘mechanize’
agent = WWW::Mechanize.new
page = agent.get(http://www.google.com)
form = page.forms[0]
google_form.q = 'ruby mechanize'
page = agent.submit(form)
puts page.body
%>
[Tue Apr 03 14:48:43 2007] [error] mod_ruby:
/usr/local/lib/ruby/1.8/net/http.rb:560:in initialize': getaddrinfo: Temporary failure in name resolution (SocketError) 2902 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from /usr/local/lib/ruby/1.8/net/http.rb:560:in
open’
2903 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from
/usr/local/lib/ruby/1.8/net/http.rb:560:in connect' 2904 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from /usr/local/lib/ruby/1.8/timeout.rb:48:in
timeout’
2905 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from
/usr/local/lib/ruby/1.8/timeout.rb:76:in timeout' 2906 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from /usr/local/lib/ruby/1.8/net/http.rb:560:in
connect’
2907 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from
/usr/local/lib/ruby/1.8/net/http.rb:553:in do_start' 2908 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from /usr/local/lib/ruby/1.8/net/http.rb:542:in
start’
2909 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from
/usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.5/lib/mechanize.rb:
390:in
fetch_page' 2910 [Tue Apr 03 14:48:43 2007] [error] mod_ruby: from /usr/local/lib/ruby/gems/1.8/gems/mechanize-0.6.5/lib/mechanize.rb: 160:in
get’
However if I run the same script from command line, it works fine.
Does somebody know how can I make this work from the web page ?