proxy_list 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c51892cbf975069f356d92fb168b9d181b652daf
4
- data.tar.gz: 1ad2d09cff9e82492fb64a69b938160cdcc2a96b
3
+ metadata.gz: 85bfdd544c66b2e0982a0b91b68b99485fbf8a7f
4
+ data.tar.gz: c9fb305fca79235196a29f52da1ff8afa6a02da5
5
5
  SHA512:
6
- metadata.gz: 50f7ab472df018cfdc13c01ad8d56ab3cfdeed29b668cbfbc1aaca5d9a92f19a55c1dea6a6c1dd2c88b7fa08ef4e595f2a8f67370ab4be670b78bc10e8f9b30e
7
- data.tar.gz: 378ab040f2fbfbc14ae7cd16d195b6303ebcc6bf46e08f4bc995324d45835ef3975d5069594da903f85aa29eed4483a8356b487b535f38ee10d0830e0735be98
6
+ metadata.gz: 30d4e20af049309ee2ae65c8c7f16c07b90885418cd0933cb945ec967d54aaae59bfa13efb134b7284ce07e41b70ef0e3eba02feaf9e4c27bba7968cda702ea6
7
+ data.tar.gz: 05dffee7013d08d43323143da3fdc21a153ca0ab868bd40c13f1afab52a6f8405d787cee028a6997f161fcb599d1fb0497cbd837256e0ad9c1b83b4537491931
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: Q4HvzSOz25mLF0WIL7wTqk9TudN7q1OyG
@@ -1,3 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.3
6
+ - 2.1.4
7
+ - 2.1.5
8
+ bundler_args: --jobs=2
9
+ script: bundle exec rspec
10
+ branches:
11
+ only:
12
+ - master
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
  #gem 'nokogiri', '~> 1.6.6.2'
6
6
  gem 'capybara', '~> 2.4.4'
7
7
  gem 'poltergeist', '~> 1.5.1'
8
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
- # ProxyList
1
+ # ProxyList
2
+ [![Build Status](https://travis-ci.org/tatsu07/proxy_list.svg?branch=master)](https://travis-ci.org/tatsu07/proxy_list) [![Coverage Status](https://coveralls.io/repos/tatsu07/proxy_list/badge.svg)](https://coveralls.io/r/tatsu07/proxy_list)
2
3
 
3
- TODO: Write a gem description
4
+ Get Free Proxy List
5
+
6
+ ## Environment
7
+
8
+ ・[phantomjs](http://phantomjs.org/)
4
9
 
5
10
  ## Installation
6
11
 
@@ -20,7 +25,15 @@ Or install it yourself as:
20
25
 
21
26
  ## Usage
22
27
 
23
- TODO: Write usage instructions here
28
+ The country of proxy you can get by specifying the ISO country code
29
+
30
+ ```ruby
31
+ require 'proxy_list'
32
+ #default US free proxy
33
+ proxy_list = ProxyList.get_lists
34
+ #useage country code
35
+ proxy_list = ProxyList.get_lists('GB')
36
+ ```
24
37
 
25
38
  ## Contributing
26
39
 
@@ -9,7 +9,9 @@ require 'proxy_list/site_freeproxylists'
9
9
  require 'proxy_list/site_cybersyndrome'
10
10
  require 'proxy_list/site_spys'
11
11
 
12
+ Capybara.current_driver = :poltergeist
12
13
  Capybara.javascript_driver = :poltergeist
14
+ Capybara.run_server = false
13
15
  Capybara.register_driver :poltergeist do |app|
14
16
  Capybara::Poltergeist::Driver.new(app,{:js_errors => false,:timeout => 1000,
15
17
  :debug => false,:inspector => false,
@@ -23,5 +25,8 @@ module ProxyList
23
25
  # @params [String] country_code ISO two byte code
24
26
  def self.get_lists(country_code='US')
25
27
  proxy_lists = ProxyList::SiteFreeproxylists.new(country_code).proxy_lists
28
+ proxy_lists.concat(ProxyList::SiteSpys.new(country_code).proxy_lists)
29
+ proxy_lists.concat(ProxyList::SiteCybersyndrome.new(country_code).proxy_lists)
30
+ proxy_lists.uniq
26
31
  end
27
32
  end
@@ -1,25 +1,29 @@
1
1
  # encoding : utf-8
2
2
  module ProxyList
3
3
  class SiteCybersyndrome
4
- @url = "http://www.cybersyndrome.net/search.cgi?q=COUNTRY_CODE"
4
+ @@url = "http://www.cybersyndrome.net/search.cgi?q=COUNTRY_CODE"
5
5
  ##
6
6
  # initialize
7
7
  # @params [String] country_code
8
8
  def initialize(country_code)
9
- @url.gsub!(/COUNTRY_CODE/,country_code)
9
+ @@url.gsub!(/COUNTRY_CODE/,country_code)
10
10
  end
11
11
 
12
12
  ##
13
13
  # get proxy lists
14
14
  # @return [Array] proxy_lists
15
15
  def proxy_lists
16
- # TODO for javascript site
17
- html = open(url,{'User-Agent' => USER_AGENTS.sample}).read
18
- doc = Nokogiri.HTML(html)
16
+ session = Capybara::Session.new(:poltergeist)
17
+ session.driver.headers = {'User-Agent' => USER_AGENTS.sample}
18
+ session.visit(@@url)
19
19
  proxy_lists = []
20
- doc.xpath("id('div_result')/table//tr/td[2]").each do |node|
21
- proxy_lists.push(node.text)
20
+ session.all(:xpath,"id('div_result')/table//tr/td[2]").each do |node|
21
+ if !node.text.nil?
22
+ proxy_lists.push("http://#{node.text}")
23
+ end
22
24
  end
25
+ Capybara.reset_sessions!
26
+ session.driver.quit
23
27
  proxy_lists
24
28
  end
25
29
  end
@@ -22,6 +22,8 @@ module ProxyList
22
22
  proxy_lists.push("#{node.find(:xpath,'td[3]').text.downcase}://#{node.find(:xpath,'td[1]').text}:#{node.find(:xpath,'td[2]').text}")
23
23
  end
24
24
  end
25
+ Capybara.reset_sessions!
26
+ session.driver.quit
25
27
  proxy_lists
26
28
  end
27
29
 
@@ -1,13 +1,13 @@
1
1
  # encoding : utf-8
2
2
  module ProxyList
3
3
  class SiteSpys
4
- @url = "http://spys.ru/free-proxy-list/COUNTRY_CODE/"
4
+ @@url = "http://spys.ru/free-proxy-list/COUNTRY_CODE/"
5
5
 
6
6
  ##
7
7
  # initialize
8
8
  # @params [String] country_code
9
9
  def initialize(country_code)
10
- @url.gsub!(/COUNTRY_CODE/,country_code)
10
+ @@url.gsub!(/COUNTRY_CODE/,country_code)
11
11
  end
12
12
 
13
13
 
@@ -15,18 +15,22 @@ module ProxyList
15
15
  # get proxy lists
16
16
  # @return [Array] proxy_lists
17
17
  def proxy_lists
18
- # TODO for javascript site
19
- html = open(url,{'User-Agent' => USER_AGENTS.sample}).read
20
- doc = Nokogiri.HTML(html)
18
+ session = Capybara::Session.new(:poltergeist)
19
+ session.driver.headers = {'User-Agent' => USER_AGENTS.sample}
20
+ session.visit(@@url)
21
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'
22
+ session.all(:xpath,"//table[2]//tr[4]/td/table//tr[position()>3]").each do |node|
23
+ if !node.text.nil? && node.has_xpath?('td[2]/font')
24
+ if node.find(:xpath,'td[2]/font').text.include?('HTTP')
25
+ http = 'http'
26
+ else
27
+ http = 'https'
28
+ end
29
+ proxy_lists.push("#{http}://#{node.find(:xpath,'td[1]/font[2]').text}")
27
30
  end
28
- proxy_lists.push("#{http}://#{node.xpath('td[1]/font[2]').text}")
29
31
  end
32
+ Capybara.reset_sessions!
33
+ session.driver.quit
30
34
  proxy_lists
31
35
  end
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module ProxyList
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "capybara",'~> 2.4.4'
25
+ spec.add_development_dependency 'poltergeist', '~> 1.5.1'
24
26
  end
@@ -8,5 +8,21 @@ describe ProxyList do
8
8
  it 'get proxy list' do
9
9
  puts ProxyList.get_lists
10
10
  expect(ProxyList.get_lists.count).to be > 0
11
+ puts ProxyList.get_lists('GB')
12
+ expect(ProxyList.get_lists.count).to be > 0
13
+ puts ProxyList.get_lists('JP')
14
+ expect(ProxyList.get_lists.count).to be > 0
15
+ puts ProxyList.get_lists('KR')
16
+ expect(ProxyList.get_lists.count).to be > 0
17
+ # puts ProxyList.get_lists('TW')
18
+ # expect(ProxyList.get_lists.count).to be > 0
19
+ # puts ProxyList.get_lists('HK')
20
+ # expect(ProxyList.get_lists.count).to be > 0
21
+ # puts ProxyList.get_lists('CN')
22
+ # expect(ProxyList.get_lists.count).to be > 0
23
+ # puts ProxyList.get_lists('CA')
24
+ # expect(ProxyList.get_lists.count).to be > 0
25
+ # puts ProxyList.get_lists('FR')
26
+ # expect(ProxyList.get_lists.count).to be > 0
11
27
  end
12
28
  end
@@ -1,5 +1,4 @@
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
3
+ require 'coveralls'
4
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tatsunori_nishikori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.4.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.4.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: poltergeist
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.5.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.1
55
83
  description: get free proxy list
56
84
  email:
57
85
  - tora.1986.tatsu@gmail.com
@@ -59,6 +87,7 @@ executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
90
+ - ".coveralls.yml"
62
91
  - ".gitignore"
63
92
  - ".rspec"
64
93
  - ".ruby-version"