M
Mark
Hi all. I am relatively new to Ruby. I have been trying to get
Mechanize to work with a proxy server and I am not having much luck. I
have tried searching and worked on this for many hours without luck. I
am sure that I am missing something
I am simply trying to get Mechanize to work using a proxy server. I am
using Mechanize 0.4.3.
I added the following function (which I realize is not necessary) in
mechanize.rb:
# This should set up a proxy if the method is called
def set_proxy(addr,port,user=nil,pass=nil)
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass = addr, port,
user, pass
end
I also updated the "fetch_page" function to be:
http = Net::HTTP:roxy(@proxy_addr, @proxy_port, @proxy_user,
@proxy_pass).new(uri.host, uri.port)
instead of
http = Net::HTTP.new(uri.host, uri.port)
I call the function via another file containing:
page = agent.set_proxy('X.X.X.X', 80) #proxy address removed
page = agent.get("http://192.168.1.100/")
This works, so long as I don't set a proxy server address and port.
I know that the proxy server is working because this:
# Example
proxy_class = Net::HTTP:roxy('X.X.X.X', 80) #proxy address removed
proxy_class.start('www.google.com') {|http|
# connecting proxy.foo.org:8080
}
returns a valid value.
Could someone please give me a hand? I would appreciate the help.
Thanks!
Mark
Mechanize to work with a proxy server and I am not having much luck. I
have tried searching and worked on this for many hours without luck. I
am sure that I am missing something
I am simply trying to get Mechanize to work using a proxy server. I am
using Mechanize 0.4.3.
I added the following function (which I realize is not necessary) in
mechanize.rb:
# This should set up a proxy if the method is called
def set_proxy(addr,port,user=nil,pass=nil)
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass = addr, port,
user, pass
end
I also updated the "fetch_page" function to be:
http = Net::HTTP:roxy(@proxy_addr, @proxy_port, @proxy_user,
@proxy_pass).new(uri.host, uri.port)
instead of
http = Net::HTTP.new(uri.host, uri.port)
I call the function via another file containing:
page = agent.set_proxy('X.X.X.X', 80) #proxy address removed
page = agent.get("http://192.168.1.100/")
This works, so long as I don't set a proxy server address and port.
I know that the proxy server is working because this:
# Example
proxy_class = Net::HTTP:roxy('X.X.X.X', 80) #proxy address removed
proxy_class.start('www.google.com') {|http|
# connecting proxy.foo.org:8080
}
returns a valid value.
Could someone please give me a hand? I would appreciate the help.
Thanks!
Mark