lib/active_proxy/fetcher.rb in active_proxy-1.0.1 vs lib/active_proxy/fetcher.rb in active_proxy-1.0.2
- old
+ new
@@ -36,20 +36,27 @@
log_message "Got new proxy #{_proxy}"
_proxy
end
return proxy unless proxy.nil?
cache_store.delete(cache_key("list"))
+ cache_store.delete(cache_key("current"))
+ sleep 0.5
+ proxy_list.sample
+
current_proxy
end
def user_agent(options = {})
UserAgentRandomizer::UserAgent.fetch(options).string
end
private
def cache_key(item_name)
- "HTTP-PROXY-#{proxy_key}-#{Process.pid}-#{item_name}"
+ if options[:unique_per_process]
+ return "HTTP-PROXY-#{proxy_key}-#{Process.pid}-#{item_name}"
+ end
+ "HTTP-PROXY-#{proxy_key}-#{item_name}"
end
def proxy_list
allowed_schemes = %w[http https]