baidu 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/baidu.rb +5 -2
- metadata +2 -2
data/lib/baidu.rb
CHANGED
@@ -106,14 +106,17 @@ class BaiduResult
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def ranks
|
109
|
-
@ranks ||= @page.search("//table[@class=\"result\"]").map{|table|@page.search("//table[@id=\"#{table['id']}\"]//
|
109
|
+
@ranks ||= @page.search("//table[@class=\"result\"]").map{|table|@page.search("//table[@id=\"#{table['id']}\"]//span[@class=\"g\"]").first}.map{|rank|rank.text unless rank.nil?}
|
110
110
|
end
|
111
111
|
|
112
112
|
#look up a word and get the rank of a uri with $host
|
113
113
|
def rank(host)#on base of ranks
|
114
114
|
ranks.each_with_index do |uri,index|
|
115
|
-
|
115
|
+
next if uri.nil?
|
116
|
+
return index+1 if uri.split('/')[0].strip == host
|
117
|
+
#return index+1 if URI.parse(URI.encode(uri)).host == host
|
116
118
|
end
|
119
|
+
return nil
|
117
120
|
end
|
118
121
|
|
119
122
|
def how_many
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baidu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project:
|
42
|
-
rubygems_version: 1.8.
|
42
|
+
rubygems_version: 1.8.24
|
43
43
|
signing_key:
|
44
44
|
specification_version: 3
|
45
45
|
summary: to get keyword ranking,related queries and popularity from baidu.com. this
|