rank_checker 0.0.2 → 0.0.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/lib/rank_checker.rb CHANGED
@@ -12,7 +12,7 @@ module RankChecker
12
12
  unless search.nil? or domain.nil?
13
13
  found = false
14
14
  page = 0
15
- pattern = /^.*q=(.*)&sa.*$/i
15
+ patterns = [/^.*q=(.*)&sa.*$/i, /^.*url=(.*)&sa.*$/i]
16
16
 
17
17
  while not found and page <= search_depth
18
18
  page += 1
@@ -21,14 +21,23 @@ module RankChecker
21
21
  doc = Nokogiri::HTML(open("https://www.google.com/search?q=#{CGI::escape(search)}&start=#{position}&sa=N"))
22
22
 
23
23
  doc.css('.r a').each do |link|
24
+ host = ''
24
25
  position += 1
25
- host = URI.parse(link.attributes['href'].value.match(pattern)[1]).host
26
26
 
27
+ patterns.each do |pattern|
28
+ page_url = link.attributes['href'].value.match(pattern)
29
+ if not page_url.nil?
30
+ host = URI.parse(page_url[1]).host
31
+ break
32
+ end
33
+ end
34
+
27
35
  if not host.nil? and host.gsub('www.', '') == domain.gsub('www.', '')
28
36
  found = true
29
37
  break
30
38
  end
31
39
  end
40
+
32
41
  end
33
42
 
34
43
  position = nil if found == false
@@ -1,3 +1,3 @@
1
1
  module RankChecker
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rank_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-16 00:00:00.000000000 Z
12
+ date: 2014-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler