Class: Ripli::HideMyName

Inherits:
CustomParser show all
Defined in:
lib/ripli/hidemyname.rb

Constant Summary collapse

PROXIES_ON_PAGE =
64
THREADS_COUNT =
3
PROXY_TYPES_ON_SITE =
{
  https: 's',
  socks4: '4',
  socks5: '5'
}.freeze
BASE_URL =
'https://hidemy.name/ru/proxy-list/?maxtime=%<max_timeout>d&type=%<type>s&anon=34&start=%<start>d#list'

Constants inherited from CustomParser

CustomParser::DEFAULT_MAX_TIMEOUT, CustomParser::DEFAULT_MECHANIZE_TIMEOUT, CustomParser::LOG_DIR

Instance Method Summary collapse

Methods inherited from CustomParser

#initialize, #shell_exec!

Constructor Details

This class inherits a constructor from Ripli::CustomParser

Instance Method Details

#parse(type, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ripli/hidemyname.rb', line 16

def parse(type, opts = {})
  @type ||= type
  url = format(BASE_URL,
               max_timeout: opts[:max_timeout] || DEFAULT_MAX_TIMEOUT,
               type: PROXY_TYPES_ON_SITE[type.to_sym],
               start: opts[:start] || 0)
  doc = @mechanize.get(url)
  proxies = extract_proxies(doc)
  proxies += paginate(doc) if opts[:start].to_i.zero?
  proxies
rescue Net::OpenTimeout, Net::ReadTimeout
  @log.error '[HideMyName] Sorry, site is unavailable!'
end