baidu 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/baidu.rb +8 -0
  2. metadata +1 -1
@@ -19,6 +19,12 @@ class Baidu
19
19
  m = /\[([^\]]*)\]/.match json
20
20
  return JSON.parse m[0]
21
21
  end
22
+ #to find out the real url for something lik 'www.baidu.com/link?url=7yoYGJqjJ4zBBpC8yDF8xDhctimd_UkfF8AVaJRPKduy2ypxVG18aRB5L6D558y3MjT_Ko0nqFgkMoS'
23
+ def url(id)
24
+ a = Mechanize.new
25
+ a.redirect_ok=false
26
+ return a.get("http://www.baidu.com/link?url=#{id}").header['location']
27
+ end
22
28
 
23
29
  =begin
24
30
  def extend(words,level=3,sleeptime=1)
@@ -162,4 +168,6 @@ class BaiduResult
162
168
  def next
163
169
  @page = BaiduResult.new(Mechanize.new.click(@page.link_with(:text=>/下一页/))) unless @page.link_with(:text=>/下一页/).nil?
164
170
  end
171
+
165
172
  end
173
+ puts Baidu.new.url('7yoYGJqjJ4zBBpC8yDF8xDhctimd_UkfF8AVaJRPKduy2ypxVG18aRB5L6D558y3MjT_Ko0nqFgkMoS')
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.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: