get_proxy_list 0.1.0 → 0.1.1

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTUzYzc1OWYyOTU3MzI2M2NiY2FmNGUyYjBjYTc3ZDNhYjdlZDliMg==
4
+ NWMwNDdjYjQwZTMwZTE2MTg1ZmIxNGI2NTk4NDlhMDdmNGM5MDEyMg==
5
5
  data.tar.gz: !binary |-
6
- YzEyYzA3ODJiODZjNDllMWY4ZDZjODliNzM0OTJmZmU4N2UwMzI4NQ==
6
+ ZGNhOTBjMDAwNzIzZTZjNGY1YWY5MTU4MDdmNWMxZWQzZGM3Zjc1Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGI5YTBmYTkxYmExMjc5ZDU2NjlmMDIzMDcxNTY2YWQwMmZhMzliMzM3NWU2
10
- MWY3ZTJhMTk1ODllYzFmZmM3MjRjYWU2NDQ2MWU2ZmI3MmI0NTY5OWIwYTlm
11
- YTNiNmVjZjhjN2Q5YTM4ODExMDAyYjZhMTc5NDZmMjA1NGRmYTg=
9
+ OGJmMjIwODcyNzcwZWM5Mjk4M2UxZmYxMGMzNWRmZmYyNjFhYjMxZjU2NmU0
10
+ MzI3NzVjMTY3N2IxOWNkMTU1NzhiODk4MDM0MWExMDlkMmM5MTIwMGU2NGM4
11
+ MTNhNzA4Mzk5Y2UzNzlmZTg3OTFiNjEyYjQyZWQyZTkyMzE4ZmI=
12
12
  data.tar.gz: !binary |-
13
- OTcxNDcwNDAzOGFkZmJiMmMzNzU1ZTJjZmFhZDE1MjI3YWJiYWY3NzRhZjRm
14
- ZDliZTM3Y2I4MTIxNjUyMmFjNDI3MGU2ZGI1NGUyYTY2YTRmYzdiYmZlMGQ4
15
- MGVjODI3ZmU4NWY5OTVkNjU3NGMxMTVjYWJhZDc3NzJmZmVjMTM=
13
+ MTA4MDllYTEzYjE3NzAyNjAyMjA5Yzk4NzEwOWU2MjgzZjgxNmRlNTc0YTU1
14
+ Y2U5Y2E2YjcxYjBhNDcwNzBiZWM5OGU5NGQ2NGE5Y2QyZmNiMWZjZWIyYjk2
15
+ MjAyOTY0OTM5NmRmZGIwMTk4NzlhYzkwYThmYmVmZTMxNGFlZTU=
data/lib/debug.rb CHANGED
@@ -6,7 +6,7 @@ require File.expand_path("../get_proxy_list", __FILE__)
6
6
  class Debug
7
7
  # To change this template use File | Settings | File Templates.
8
8
  include GetProxyList
9
- list= GetProxyList.get_list(5,4)
9
+ list= GetProxyList.get_list(0,4)
10
10
  p "Size: #{list.size}"
11
11
  p "list: #{list}"
12
12
  end
@@ -16,7 +16,7 @@ module GetProxyList
16
16
  def _getproxylist(url)
17
17
  begin
18
18
  hash_port = {"c"=>"1","a"=>"2","z"=>"3","m"=>"4","b"=>"5","w"=>"6","i"=>"7","x"=>"8","l"=>"9","f"=>"0"}
19
- html = open(url ).read
19
+ html = open(url).read
20
20
  html.force_encoding("gbk")
21
21
  html.encode!("utf-8", :undef => :replace, :replace => "", :invalid => :replace)
22
22
  doc=Nokogiri::HTML.parse html
@@ -1,3 +1,3 @@
1
1
  module Getproxylist
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -10,4 +10,37 @@ module GetProxyList
10
10
  proxylist = base.get_proxy_in_time_limit(limit,proxylist)
11
11
  return proxylist
12
12
  end
13
+
14
+ def self.get_proxy_in_time_limt(limit,proxylist)
15
+ limit_list = []
16
+ proxylist.each do |proxy|
17
+ url = proxy
18
+ time_start = Time.now.to_i
19
+ begin
20
+ timeout(limit+1) do
21
+ doc = Nokogiri::HTML(open("http://www.baidu.com",:proxy=> url))
22
+ x = doc.css("em")
23
+ end
24
+ time_end = Time.now.to_i
25
+ time_use = time_end - time_start
26
+ p "url use_time:#{time_use}"
27
+ rescue Exception =>e
28
+ case e
29
+ when Errno::ETIMEDOUT
30
+ p "Use #{url} timeout"
31
+ when Timeout::Error
32
+ p "Use #{url} timeout"
33
+ when Errno::ECONNREFUSED
34
+ p "Use #{url} Error connection"
35
+ else
36
+ p "Use #{url} Error:#{e.to_s}"
37
+ end
38
+ time_use = -1
39
+ end
40
+ if(time_use > 0 &&time_use < limit)
41
+ limit_list << url
42
+ end
43
+ end
44
+ limit_list
45
+ end
13
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_proxy_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - hahazql