hidemyass 0.1.2 → 0.1.3

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.
data/README.md CHANGED
@@ -58,6 +58,7 @@ or simply run:
58
58
 
59
59
  ## Roadmap
60
60
 
61
+ * Improve the quality of returned proxies: currently I'm using the custom search url, but it seems to expire every n-days
61
62
  * Get proxies from other pages
62
63
  * Improve tests suite
63
64
  * Clean code and refactor
data/lib/hidemyass.rb CHANGED
@@ -12,8 +12,7 @@ module HideMyAss
12
12
  extend Logger
13
13
 
14
14
  SITE = "http://hidemyass.com".freeze
15
- # TODO: Find a way to get ideal results in the custom search
16
- ENDPOINT = "http://hidemyass.com/proxy-list/search-750598".freeze
15
+ ENDPOINT = "http://hidemyass.com/proxy-list/".freeze
17
16
 
18
17
  LOG_PREFIX = '** [hidemyass] '
19
18
 
@@ -21,6 +20,7 @@ module HideMyAss
21
20
  Errno::EINVAL,
22
21
  Errno::ECONNRESET,
23
22
  Errno::ECONNREFUSED,
23
+ Errno::ETIMEDOUT,
24
24
  EOFError,
25
25
  Net::HTTPBadResponse,
26
26
  Net::HTTPHeaderSyntaxError,
@@ -36,7 +36,10 @@ module HideMyAss
36
36
 
37
37
  def self.proxies
38
38
  clear_cache if options[:clear_cache]
39
- html = Nokogiri::HTML(open(URI.parse(ENDPOINT))) unless @proxies
39
+
40
+ unless @proxies
41
+ html = get_hma_body
42
+ end
40
43
 
41
44
  @proxies ||= html.xpath('//table[@id="listtable"]/tr').collect do |node|
42
45
  ip = HideMyAss::IP.new(node.at_xpath('td[2]/span'))
@@ -51,4 +54,34 @@ module HideMyAss
51
54
  def self.clear_cache
52
55
  @proxies = nil
53
56
  end
57
+
58
+ private
59
+
60
+ def self.get_hma_body
61
+ data = {
62
+ "c[]" => ["United States"],
63
+ "p" => nil,
64
+ "pr[]" => [0,1,2],
65
+ "a[]" => [0,1,2,3],
66
+ "sp[]" => [2,3],
67
+ "ct[]" => [2,3],
68
+ "s" => 0,
69
+ "o" => 0,
70
+ "pp" => 2,
71
+ "sortBy" => "date"
72
+ }
73
+
74
+ res = Net::HTTP.post_form(URI(ENDPOINT), data)
75
+
76
+ body = case res
77
+ when Net::HTTPSuccess then
78
+ res.body
79
+ when Net::HTTPRedirection then
80
+ Net::HTTP.get_response(URI(SITE + res['location'])).body
81
+ else
82
+ res.value
83
+ end
84
+
85
+ return Nokogiri::HTML(body)
86
+ end
54
87
  end
@@ -1,3 +1,3 @@
1
1
  module HideMyAss
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/spec/lib/ip_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe HideMyAss::IP do
6
6
  # but hidemyass.com seems to be changing their encoding strategy often.
7
7
  # By having real data we ensure this gem is working.
8
8
  it "decodes encoded address" do
9
- html = Nokogiri::HTML(open(URI.parse(HideMyAss::ENDPOINT)))
9
+ html = HideMyAss.get_hma_body
10
10
 
11
11
  HideMyAss::IP.new(html.at_xpath('//table[@id="listtable"]/tr/td[2]/span'))
12
12
  .should be_valid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hidemyass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-30 00:00:00.000000000 Z
12
+ date: 2012-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70096109251860 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.5.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70096109251860
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.5
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70096109251360 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: 2.12.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70096109251360
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.12.0
36
46
  description: Hide My Ass! fetches and connects to proxies at www.hidemyass.com
37
47
  email:
38
48
  - javier@tractical.com
@@ -76,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
86
  version: '0'
77
87
  requirements: []
78
88
  rubyforge_project:
79
- rubygems_version: 1.8.11
89
+ rubygems_version: 1.8.23
80
90
  signing_key:
81
91
  specification_version: 3
82
92
  summary: Hide My Ass! lets you connect anonymously, fetch proxies from hidemyass.com