Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem

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://www.google.com/
page=page.link_with(:dom_class => “button”).click()

But my bad getting the below error within my company,but the same was
running in my home desktop well. Any suggestion how to break
firewall/stie blocker and do the work in company also?

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
`’

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

On Tue, Jan 22, 2013 at 3:52 PM, Arup R. [email protected]
wrote:

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

Could you please me to fix the same?

Maybe it’s the DNS setup on the company machine or how Ruby interacts
with DNS there.

Kind regards

robert

Robert K. wrote in post #1093173:

On Tue, Jan 22, 2013 at 3:52 PM, Arup R. [email protected]
wrote:

Maybe it’s the DNS setup on the company machine or how Ruby interacts
with DNS there.

Kind regards

robert

The link is opened and workable on my each browser - ‘IE-9’,‘firefox’
both. But it is not with the script as mentioned above. So any work
around on that? Really it is painful for me. This Gem has good
fetures,but couldn’t use it. The same problem with “Nokogiri” also.

Thanks,

Robert K. wrote in post #1093191:

On Tue, Jan 22, 2013 at 6:53 PM, Arup R. [email protected]
wrote:

Robert K. wrote in post #1093173:

On Tue, Jan 22, 2013 at 3:52 PM, Arup R. [email protected]
wrote:

Maybe it’s the DNS setup on the company machine or how Ruby interacts
with DNS there.

I didn’t get you. cloud you explain the syntax or give me a sample code
which you want me to do eliminate the error?

Thanks,
Arup

On Wed, Jan 23, 2013 at 1:53 AM, Arup R. [email protected]
wrote:

The link is opened and workable on my each browser - ‘IE-9’,‘firefox’
both. But it is not with the script as mentioned above. So any work
around on that? Really it is painful for me. This Gem has good
fetures,but couldn’t use it. The same problem with “Nokogiri” also.

check if you’re behind a proxy

kind regards -botp

On Tue, Jan 22, 2013 at 6:53 PM, Arup R. [email protected]
wrote:

Robert K. wrote in post #1093173:

On Tue, Jan 22, 2013 at 3:52 PM, Arup R. [email protected]
wrote:

Maybe it’s the DNS setup on the company machine or how Ruby interacts
with DNS there.

The link is opened and workable on my each browser - ‘IE-9’,‘firefox’
both. But it is not with the script as mentioned above. So any work
around on that? Really it is painful for me. This Gem has good
fetures,but couldn’t use it. The same problem with “Nokogiri” also.

Nokogiri will not open remote connections. It’s just for parsing XML,
HTML and the like. Unless I am overlooking something.

Did you try to open a connection to that port using TCPSocket to
verify the underlying mechanics work?

Kind regards

robert

botp wrote in post #1093207:

On Wed, Jan 23, 2013 at 1:53 AM, Arup R. [email protected]
wrote:

The link is opened and workable on my each browser - ‘IE-9’,‘firefox’
both. But it is not with the script as mentioned above. So any work
around on that? Really it is painful for me. This Gem has good
fetures,but couldn’t use it. The same problem with “Nokogiri” also.

check if you’re behind a proxy

kind regards -botp

Yes,We are using Proxy. Is the proxy only reason for that error? how I
need to set proxy with my script?

Thanks,
Arup

Arup R. wrote in post #1093518:

Is there anyway I can eliminate all the above errors and can work with
“mechanize” inside the “firewall”?

If your browser works you can use webdriver with the browser and its
default profile, and then let Nokogiri handle the HTML once you’ve
aquired the target page.

Arup R. wrote in post #1093223:

botp wrote in post #1093207:

On Wed, Jan 23, 2013 at 1:53 AM, Arup R. [email protected]
wrote:

The link is opened and workable on my each browser - ‘IE-9’,‘firefox’
both. But it is not with the script as mentioned above. So any work
around on that? Really it is painful for me. This Gem has good
fetures,but couldn’t use it. The same problem with “Nokogiri” also.

Is there anyway I can eliminate all the above errors and can work with
“mechanize” inside the “firewall”?

Thanks,