proxy_list 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15582f80fed77a826d66efa6ef064c2b01c9aec6
4
- data.tar.gz: f38d254e6a6e160390f658eb08f0865ef8914db2
3
+ metadata.gz: c51892cbf975069f356d92fb168b9d181b652daf
4
+ data.tar.gz: 1ad2d09cff9e82492fb64a69b938160cdcc2a96b
5
5
  SHA512:
6
- metadata.gz: adf2b30b816991a17df8b7067d943eb7437c8a754aa422fbc4b734a05e0e5ab34b4686c00e240d2ff2093a4a373377e8a0382a68e1bd855ee44beed513f259c6
7
- data.tar.gz: b94398f5ab833f9d3fd0d89e6aa899b4d442dacc3c94c182547c2f911eb6d04c6a45bb1386dc227cbab2808d706a3553bf545b76e8532836fead640788e5f8b2
6
+ metadata.gz: 50f7ab472df018cfdc13c01ad8d56ab3cfdeed29b668cbfbc1aaca5d9a92f19a55c1dea6a6c1dd2c88b7fa08ef4e595f2a8f67370ab4be670b78bc10e8f9b30e
7
+ data.tar.gz: 378ab040f2fbfbc14ae7cd16d195b6303ebcc6bf46e08f4bc995324d45835ef3975d5069594da903f85aa29eed4483a8356b487b535f38ee10d0830e0735be98
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
  mkmf.log
15
15
  .rbenv-gemsets
16
16
  *.gem
17
+ log/
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in proxy_list.gemspec
4
4
  gemspec
5
+ #gem 'nokogiri', '~> 1.6.6.2'
6
+ gem 'capybara', '~> 2.4.4'
7
+ gem 'poltergeist', '~> 1.5.1'
@@ -1,5 +1,27 @@
1
+ # encoding : utf-8
2
+ #require 'open-uri'
3
+ #require 'nokogiri'
4
+ require 'capybara'
5
+ require 'capybara/poltergeist'
1
6
  require "proxy_list/version"
7
+ require "proxy_list/user_agents"
8
+ require 'proxy_list/site_freeproxylists'
9
+ require 'proxy_list/site_cybersyndrome'
10
+ require 'proxy_list/site_spys'
2
11
 
12
+ Capybara.javascript_driver = :poltergeist
13
+ Capybara.register_driver :poltergeist do |app|
14
+ Capybara::Poltergeist::Driver.new(app,{:js_errors => false,:timeout => 1000,
15
+ :debug => false,:inspector => false,
16
+ :phantomjs_logger => File.open(File.expand_path('../../log/phantomjs.log',__FILE__),'a')
17
+ })
18
+ end
3
19
  module ProxyList
4
- # Your code goes here...
20
+
21
+ ##
22
+ # get proxy lists
23
+ # @params [String] country_code ISO two byte code
24
+ def self.get_lists(country_code='US')
25
+ proxy_lists = ProxyList::SiteFreeproxylists.new(country_code).proxy_lists
26
+ end
5
27
  end
@@ -0,0 +1,26 @@
1
+ # encoding : utf-8
2
+ module ProxyList
3
+ class SiteCybersyndrome
4
+ @url = "http://www.cybersyndrome.net/search.cgi?q=COUNTRY_CODE"
5
+ ##
6
+ # initialize
7
+ # @params [String] country_code
8
+ def initialize(country_code)
9
+ @url.gsub!(/COUNTRY_CODE/,country_code)
10
+ end
11
+
12
+ ##
13
+ # get proxy lists
14
+ # @return [Array] proxy_lists
15
+ def proxy_lists
16
+ # TODO for javascript site
17
+ html = open(url,{'User-Agent' => USER_AGENTS.sample}).read
18
+ doc = Nokogiri.HTML(html)
19
+ proxy_lists = []
20
+ doc.xpath("id('div_result')/table//tr/td[2]").each do |node|
21
+ proxy_lists.push(node.text)
22
+ end
23
+ proxy_lists
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ # encoding : utf-8
2
+ module ProxyList
3
+ class SiteFreeproxylists
4
+ @@url = "http://www.freeproxylists.net/ja/?c=COUNTRY_CODE&pt=&pr=&a[]=0&a[]=1&a[]=2&u=0"
5
+ ##
6
+ # initialize
7
+ # @params [String] country_code
8
+ def initialize(country_code)
9
+ @@url.gsub!(/COUNTRY_CODE/,country_code)
10
+ end
11
+
12
+ ##
13
+ # get proxy lists
14
+ # @return [Array] proxy_lists
15
+ def proxy_lists
16
+ session = Capybara::Session.new(:poltergeist)
17
+ session.driver.headers = {'User-Agent' => USER_AGENTS.sample}
18
+ session.visit(@@url)
19
+ proxy_lists = []
20
+ session.all(:xpath,"/html/body/div[1]/div[2]/table//tr[not(@class='Caption')]").each do |node|
21
+ if !node.text.nil? && node.has_xpath?('td[3]')
22
+ proxy_lists.push("#{node.find(:xpath,'td[3]').text.downcase}://#{node.find(:xpath,'td[1]').text}:#{node.find(:xpath,'td[2]').text}")
23
+ end
24
+ end
25
+ proxy_lists
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ # encoding : utf-8
2
+ module ProxyList
3
+ class SiteSpys
4
+ @url = "http://spys.ru/free-proxy-list/COUNTRY_CODE/"
5
+
6
+ ##
7
+ # initialize
8
+ # @params [String] country_code
9
+ def initialize(country_code)
10
+ @url.gsub!(/COUNTRY_CODE/,country_code)
11
+ end
12
+
13
+
14
+ ##
15
+ # get proxy lists
16
+ # @return [Array] proxy_lists
17
+ def proxy_lists
18
+ # TODO for javascript site
19
+ html = open(url,{'User-Agent' => USER_AGENTS.sample}).read
20
+ doc = Nokogiri.HTML(html)
21
+ proxy_lists = []
22
+ doc.xpath("/html/body/table[2]//tr[4]/td/table//tr[position() > 3]").each do |node|
23
+ if node.xpath('td[2]/font').text.include?('HTTP')
24
+ http = 'http'
25
+ else
26
+ http = 'https'
27
+ end
28
+ proxy_lists.push("#{http}://#{node.xpath('td[1]/font[2]').text}")
29
+ end
30
+ proxy_lists
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ # encoding : utf-8
2
+ module ProxyList
3
+ USER_AGENTS = [
4
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:34.0) Gecko/20100101 Firefox/34.0",
5
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36",
6
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11"
7
+ ]
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ProxyList
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,7 +5,8 @@ describe ProxyList do
5
5
  expect(ProxyList::VERSION).not_to be nil
6
6
  end
7
7
 
8
- it 'does something useful' do
9
- expect(false).to eq(true)
8
+ it 'get proxy list' do
9
+ puts ProxyList.get_lists
10
+ expect(ProxyList.get_lists.count).to be > 0
10
11
  end
11
12
  end
@@ -1,2 +1,5 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'proxy_list'
3
+ #RSpec.configure do |config|
4
+ # config.output_stream = $stdout
5
+ #end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tatsunori_nishikori
@@ -68,7 +68,12 @@ files:
68
68
  - README.md
69
69
  - Rakefile
70
70
  - lib/proxy_list.rb
71
+ - lib/proxy_list/site_cybersyndrome.rb
72
+ - lib/proxy_list/site_freeproxylists.rb
73
+ - lib/proxy_list/site_spys.rb
74
+ - lib/proxy_list/user_agents.rb
71
75
  - lib/proxy_list/version.rb
76
+ - log/.gitkeep
72
77
  - proxy_list.gemspec
73
78
  - spec/proxy_list_spec.rb
74
79
  - spec/spec_helper.rb