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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/lib/proxy_list.rb +23 -1
- data/lib/proxy_list/site_cybersyndrome.rb +26 -0
- data/lib/proxy_list/site_freeproxylists.rb +29 -0
- data/lib/proxy_list/site_spys.rb +33 -0
- data/lib/proxy_list/user_agents.rb +8 -0
- data/lib/proxy_list/version.rb +1 -1
- data/spec/proxy_list_spec.rb +3 -2
- data/spec/spec_helper.rb +3 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c51892cbf975069f356d92fb168b9d181b652daf
|
4
|
+
data.tar.gz: 1ad2d09cff9e82492fb64a69b938160cdcc2a96b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50f7ab472df018cfdc13c01ad8d56ab3cfdeed29b668cbfbc1aaca5d9a92f19a55c1dea6a6c1dd2c88b7fa08ef4e595f2a8f67370ab4be670b78bc10e8f9b30e
|
7
|
+
data.tar.gz: 378ab040f2fbfbc14ae7cd16d195b6303ebcc6bf46e08f4bc995324d45835ef3975d5069594da903f85aa29eed4483a8356b487b535f38ee10d0830e0735be98
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/proxy_list.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/proxy_list/version.rb
CHANGED
data/spec/proxy_list_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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.
|
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
|