Class: GoogleTts::ProxyFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/google_tts/proxy_fetcher.rb

Constant Summary collapse

@@SOURCES =
[
  "http://www.xroxy.com/proxyrss.xml", 
  "http://www.freeproxylists.com/rss", 
  "http://www.proxz.com/proxylists.xml"
]
@@list =
list

Class Method Summary collapse

Class Method Details

.listObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/google_tts/proxy_fetcher.rb', line 13

def self.list
  list = []
  @@SOURCES.each do |url|
    Nokogiri::XML(open url).xpath("//prx:proxy").each do |node|
      proxy = { host: node.xpath("prx:ip").text, 
                port: node.xpath("prx:port").text,
                type: node.xpath("prx:type").text,
                ssl: node.xpath("prx:ssl").text.downcase == "true" }
      list << proxy if (proxy[:type] == "Anonymous" and not proxy[:ssl])
    end
  end
  list
end

.random_proxyObject



27
28
29
# File 'lib/google_tts/proxy_fetcher.rb', line 27

def self.random_proxy
  @@list.sample
end