Class: FreshProxy
- Inherits:
-
Object
- Object
- FreshProxy
- Defined in:
- lib/fresh_proxy.rb,
lib/fresh_proxy/version.rb
Overview
Class to scrap proxies from incloak
Constant Summary collapse
- VERSION =
'0.2.3'.freeze
Instance Method Summary collapse
-
#extract_page ⇒ Object
scrap incloak page for the proxies with maxtime = 1000ms.
-
#extract_proxies ⇒ Object
get the last 64 most fresh proxies.
-
#fresh ⇒ Object
get the most fresh proxy.
-
#initialize ⇒ FreshProxy
constructor
A new instance of FreshProxy.
Constructor Details
#initialize ⇒ FreshProxy
Returns a new instance of FreshProxy.
5 6 7 |
# File 'lib/fresh_proxy.rb', line 5 def initialize @agent = Mechanize.new end |
Instance Method Details
#extract_page ⇒ Object
scrap incloak page for the proxies with maxtime = 1000ms
10 11 12 |
# File 'lib/fresh_proxy.rb', line 10 def extract_page @agent.get 'https://incloak.com/proxy-list/?maxtime=1000#list' end |
#extract_proxies ⇒ Object
get the last 64 most fresh proxies
25 26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
get the most fresh proxy
15 16 17 18 19 20 21 22 |
# 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 |