What I want to do is this
I have a proxy list with ip|port
Now Mechanize is using those proxy and I have set
open_timeout = 20
read_timeout = 20
What I want it todo is to retry, but it will retry with the same proxy even if I have "proxies = @proxies.order("RANDOM()").first" it will not load a new proxy, but instead it will load from cache
here is my code that I use :
begin
proxies = @proxies.order("RANDOM()").first
proxy_ip = proxies.ip
proxy_port = proxies.port
puts proxy_ip
puts proxy_port
agent = Mechanize.new
agent.open_timeout = 20
agent.read_timeout = 20
agent.set_proxy(proxy_ip, proxy_port)
page = agent.get("http://whatismyip.org/"
rescue
puts "oh shit, error"
retry
end
doc = page.parser
ip_ad = doc.css('span').text
puts ip_ad
Now my question is how do I make it load a new proxy instead of using it from the cache