Module: GetProxy

Defined in:
lib/proxy_rotater/public_proxy/getproxy.rb

Constant Summary collapse

URL =
"http://www.getproxy.jp/"

Class Method Summary collapse

Class Method Details

.getObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/proxy_rotater/public_proxy/getproxy.rb', line 5

def self.get
  page = HTTParty.get(URL)
  html = Nokogiri::HTML(page.body)

  tr = html.css("#mytable tr")[1..-1]
  values = tr.map do |line|
    td = line.css("td")
    matched_address = td[0].css("strong").first.content
      .match(/^((?:\d{,3})(?:\.\d{,3}){3})\:(\d{,5})$/)
    values = {
      ip_address: matched_address[1],
      port:       matched_address[2],
      country:    td[1].content
    }
  end
end