Class: Nx::XiciProxy
- Inherits:
-
Object
- Object
- Nx::XiciProxy
- Defined in:
- lib/nx/version.rb,
lib/nx/xici-proxy.rb
Constant Summary collapse
- VERSION =
"0.1.4"
Class Method Summary collapse
Class Method Details
.fetch ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nx/xici-proxy.rb', line 6 def self.fetch doc = Nokogiri::HTML( open( "https://www.xicidaili.com/wn/", read_timeout: 5, ) ) # process html use selector rows = doc.css("#ip_list tr") data = [] rows.each_with_index do |row, index| if index > 0 ip = row.css("td:nth-child(2)").text port = row.css("td:nth-child(3)").text data << { ip: ip, port: port } end end return data end |