Module: ProxyUtilities::Getter

Defined in:
lib/proxy_utilities/getter.rb

Class Method Summary collapse

Class Method Details

.get_allObject

Starting all fetching processes



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/proxy_utilities/getter.rb', line 13

def self.get_all()
  result = []
  result += self.get_free_proxy_list_net
  result += self.get_ssl_proxies_org
  result += self.get_gather_proxy_com
  result += self.get_httptunnel_ge
  result += self.get_proxy_list_org
  result += self.get_socks_proxy_list_net
  result += self.get_checker_proxy_net
  return result.uniq
end

.get_checker_proxy_netObject



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/proxy_utilities/getter.rb', line 175

def self.get_checker_proxy_net
  result = []
  url = "https://checkerproxy.net/api/archive/#{Date.today.strftime('%Y-%m-%d')}"
  page = Nokogiri::HTML(open(url))
  rows = JSON.parse(page)

  rows.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row["ip"]
      proxy[:port] = Integer(row["addr"].split(":")[1].gsub(/^0+/, ''))
      proxy[:country_code] = row["addr_geo_iso"].upcase
      anonymities = {0=>"transparent", 1=> "elite", 2=> "anonymous"}
      proxy[:anonymity] = anonymities[row["kind"]]
      types = {1=>"HTTP", 2=>"HTTPS", 3=>"SOCKS4", 4=>"SOCKS5"}
      proxy[:type] = types[row["type"]]
      result << proxy
    end
  end
  return result
end

.get_free_proxy_list_netObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/proxy_utilities/getter.rb', line 25

def self.get_free_proxy_list_net
  result = []
  url = "https://free-proxy-list.net/"
  page = Nokogiri::HTML(open(url))
  rows = page.xpath('//table[@id="proxylisttable"]/tbody/tr')

  rows.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row.xpath('td[1]').text
      proxy[:port] = Integer(row.xpath('td[2]').text.gsub(/^0+/, ''))
      proxy[:country_code] = row.xpath('td[3]').text
      proxy[:anonymity] = row.xpath('td[5]').text.gsub(" proxy", "")
      if row.xpath('td[7]').text == 'yes'
        proxy[:type] = 'HTTPS'
      else
        proxy[:type] = 'HTTP'
      end
      result << proxy
    end
  end
  return result
end

.get_gather_proxy_comObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/proxy_utilities/getter.rb', line 73

def self.get_gather_proxy_com
  result = []
  url = "http://www.gatherproxy.com/"
  page = Nokogiri::HTML(open(url))
  rows = page.xpath('//div[@class="proxy-list"]/table/script')
  javascript = rows.text[/{.+}/im].gsub("gp.insertPrx(", "").gsub(");", "")
  json = JSON.parse("[" + javascript.split("\r\n").join(",").gsub("               ,                    ", "") + "]")
  json.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row["PROXY_IP"]
      proxy[:port] = row['PROXY_PORT'].to_i(16)
      begin
        proxy[:country_code] = IsoCountryCodes.search_by_name(row["PROXY_COUNTRY"]).first.alpha2
      rescue
        proxy[:country_code] = nil
      end
      proxy[:anonymity] = row['PROXY_TYPE'].downcase
      proxy[:type] = 'HTTP'
      result << proxy
    end
  end
  return result
end

.get_httptunnel_geObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/proxy_utilities/getter.rb', line 98

def self.get_httptunnel_ge
  result = []
  url = "http://www.httptunnel.ge/ProxyListForFree.aspx"
  page = Nokogiri::HTML(open(url))
  rows = page.xpath('//table[contains(@id, "GridView")]/tr[(count(td)>2)]')

  rows.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row.xpath('td[1]').text.split(":")[0].strip
      proxy[:port] = Integer(row.xpath('td[1]').text.split(":")[1].strip)
      proxy[:country_code] = row.xpath('td[8]/img/@title').text
      transparency = row.xpath('td[5]').text.to_sym
      proxy[:anonymity] = { A: 'anonymous',  E: 'elite', T: 'transparent', U: 'unknown'}.fetch(transparency, 'Unknown')
      proxy[:type] = 'HTTP'
      result << proxy
    end
  end
  return result
end

.get_proxy_list_orgObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/proxy_utilities/getter.rb', line 119

def self.get_proxy_list_org
  result = []
  (1..10).to_a.each do |page_num|
    begin
      url = "https://proxy-list.org/english/index.php?p=#{page_num}"
      page = Nokogiri::HTML(open(url))
      rows = page.css('.table-wrap .table ul')

      rows.each do |row|
        begin
          proxy = {}
          proxy[:ip] = ::Base64.decode64(rows.first.at_css('li script').text.match(/'(.+)'/)[1]).split(":")[0].strip
          proxy[:port] = Integer(::Base64.decode64(rows.first.at_css('li script').text.match(/'(.+)'/)[1]).split(":")[1].strip)
          country_code = row.xpath('li[5]/div/span/span/span[2]').text.scan(/([A-Z]{2}) /)
          unless country_code.nil?
            begin
              proxy[:country_code] = country_code.first.first.strip
            rescue
              next
            end
          else
            next
          end
          proxy[:anonymity] = row.xpath('li[4]').text.strip.downcase
          proxy[:type] = row.xpath('li[2]').text.strip.upcase
          if proxy[:type] == "-"
            proxy[:type] = nil
          end
          result << proxy
        end
      end
    end
  end
  return result
end

.get_socks_proxy_list_netObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/proxy_utilities/getter.rb', line 155

def self.get_socks_proxy_list_net
  result = []
  url = "https://www.socks-proxy.net/"
  page = Nokogiri::HTML(open(url))
  rows = page.xpath('//table[@id="proxylisttable"]/tbody/tr')

  rows.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row.xpath('td[1]').text
      proxy[:port] = Integer(row.xpath('td[2]').text.gsub(/^0+/, ''))
      proxy[:country_code] = row.xpath('td[3]').text
      proxy[:anonymity] = row.xpath('td[6]').text.downcase
      proxy[:type] = row.xpath('td[5]').text.upcase
      result << proxy
    end
  end
  return result
end

.get_ssl_proxies_orgObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/proxy_utilities/getter.rb', line 49

def self.get_ssl_proxies_org
  result = []
  url = "https://www.sslproxies.org/"
  page = Nokogiri::HTML(open(url))
  rows = page.xpath('//table[@id="proxylisttable"]/tbody/tr')

  rows.each do |row|
    begin
      proxy = {}
      proxy[:ip] = row.xpath('td[1]').text
      proxy[:port] = Integer(row.xpath('td[2]').text.gsub(/^0+/, ''))
      proxy[:country_code] = row.xpath('td[3]').text
      proxy[:anonymity] = row.xpath('td[5]').text.gsub(" proxy", "")
      if row.xpath('td[7]').text == 'yes'
        proxy[:type] = 'HTTPS'
      else
        proxy[:type] = 'HTTP'
      end
      result << proxy
    end
  end
  return result
end