Class: Ripli::ProxyScrape
- Inherits:
-
CustomParser
- Object
- CustomParser
- Ripli::ProxyScrape
- Defined in:
- lib/ripli/proxyscrape.rb
Constant Summary collapse
- BASE_URL =
'https://api.proxyscrape.com/?request=getproxies&proxytype='
- URL_PARAMS =
{ https: 'https&timeout=%d&country=all&ssl=all&anonymity=all', socks4: 'socks4&timeout=%d&country=all', socks5: 'socks5&timeout=%d&country=all' }.freeze
Constants inherited from CustomParser
CustomParser::DEFAULT_MAX_TIMEOUT, CustomParser::DEFAULT_MECHANIZE_TIMEOUT, CustomParser::LOG_DIR
Instance Method Summary collapse
Methods inherited from CustomParser
Constructor Details
This class inherits a constructor from Ripli::CustomParser
Instance Method Details
#parse(type, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ripli/proxyscrape.rb', line 15 def parse(type, opts = {}) max_timeout = opts[:max_timeout] || DEFAULT_MAX_TIMEOUT link = [BASE_URL, URL_PARAMS[type] % max_timeout].join response = @mechanize.get(link).body response.split.map { |proxy| "#{type}\t#{proxy.sub(':', "\t\t")}" } rescue Net::OpenTimeout, Net::ReadTimeout @log.error '[ProxyScrape] Sorry, site is unavailable!' end |