class FreshProxy
Class to scrap proxies from incloak
Constants
- VERSION
Public Class Methods
new()
click to toggle source
# File lib/fresh_proxy.rb, line 5 def initialize @agent = Mechanize.new end
Public Instance Methods
extract_page()
click to toggle source
scrap incloak page for the proxies with maxtime = 1000ms
# File lib/fresh_proxy.rb, line 10 def extract_page @agent.get 'https://incloak.com/proxy-list/?maxtime=1000#list' end
extract_proxies()
click to toggle source
get the last 64 most fresh proxies
# File lib/fresh_proxy.rb, line 25 def extract_proxies extract_page.search('.//table//tbody//tr').map do |row| { ip: row.search('.//td[1]').text, port: row.search('.//td[2]').text, speed: row.search('.//td[4]').text } end end
fresh()
click to toggle source
get the most fresh proxy
# File lib/fresh_proxy.rb, line 15 def fresh page = extract_page { ip: page.search('.//table//tbody//tr[1]//td[1]').text, port: page.search('.//table//tbody//tr[1]//td[2]').text, speed: page.search('.//table//tbody//tr[1]//td[4]').text } end