2

I tried the below code:

require 'mechanize'

agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
    page = agent.get "https://gegsltraining.aravo.com/"
page=page.link_with(:dom_class => "button").click()

But my bad getting the below error.

D:\WIPData\Ruby\Scripts>mechanize_dowload.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net/http/persist
ent/ssl_reuse.rb:29:in `initialize': getaddrinfo: No such host is known.  (Socke
tError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `open'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `block in connect'
        from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
        from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `connect'
        from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
        from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:750:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:628:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:570:in `connection_for'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:926:in `request'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize/h
ttp/agent.rb:258:in `fetch'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize.r
b:407:in `get'
        from D:/WIPData/Ruby/Scripts/mechanize_dowload.rb:5:in `<main>'

D:\WIPData\Ruby\Scripts>

The same script ran perfectly on my personal machine,but not in my company.

Could you please me to fix the same?

Thanks in advance

Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • Can anyone help me here? – Arup Rakshit Jan 22 '13 at 14:46
  • This happens to me too, but not consistently, in a script of mine. I'm loading a Google website, it's unlikely to be down and DNS resolution should already be cached... It goes like this: http://p.defau.lt/?J6ywtrHAOcdzXY80xGIbrg – Nemo Dec 19 '13 at 09:48

1 Answers1

2

That error means dns is not resolving. In my experience it's usually because your internet is down.

pguardiario
  • 53,827
  • 19
  • 119
  • 159
  • My internet is ruunning. I am in my company, the script ran well in my home,not in my office. – Arup Rakshit Jan 22 '13 at 08:53
  • It is up, as I am able to open it on my browser. – Arup Rakshit Jan 22 '13 at 08:57
  • maybe you're doing something silly, like connecting through a proxy and not showing it. – pguardiario Jan 22 '13 at 09:48
  • I have tried this also `agent.set_proxy('3.209.30.25','80', user = nil, pass = nil)` with my script,still error. But yes,I checked that `ping -t www.google.com` is not working from my terminal. So any workaround can be done. May be my company policy protect me to fire the `ping`. `C:\>ping -t www.google.com Ping request could not find host www.google.com. Please check the name and try a gain.` – Arup Rakshit Jan 22 '13 at 11:04
  • Have you managed to resolve your issue? I am facing the same problem. – 8bithero Mar 12 '13 at 08:56
  • Your company probably has a Microsoft proxy. Google CNTLM for more info on how to get around it. Short version: the CNTLM proxy runs on your machine and authenticates with the non-standard M$ proxy that normal code can't deal with, and your code goes through your CNTLM proxy. There is also now a Ruby project on Github to deal with CNTLM authentication if you wanna bake the solution into your code. – iconoclast Aug 14 '13 at 18:31