Class: ProxyList::SiteCybersyndrome

Inherits:
Object
  • Object
show all
Defined in:
lib/proxy_list/site_cybersyndrome.rb

Constant Summary collapse

@@url =
"http://www.cybersyndrome.net/search.cgi?q=COUNTRY_CODE"

Instance Method Summary collapse

Constructor Details

#initialize(country_code) ⇒ SiteCybersyndrome

initialize



8
9
10
# File 'lib/proxy_list/site_cybersyndrome.rb', line 8

def initialize(country_code)
  @@url.gsub!(/COUNTRY_CODE/,country_code)
end

Instance Method Details

#proxy_listsArray

get proxy lists



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/proxy_list/site_cybersyndrome.rb', line 15

def proxy_lists
  session = Capybara::Session.new(:poltergeist)
  session.driver.headers = {'User-Agent' => USER_AGENTS.sample}
  session.visit(@@url)
  proxy_lists = []
  session.all(:xpath,"id('div_result')/table//tr/td[2]").each do |node|
    if !node.text.nil?
      proxy_lists.push("http://#{node.text}")
    end
  end
  Capybara.reset_sessions!
  session.driver.quit
  proxy_lists
end