related_words 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/related_words +1 -1
- data/lib/related_words/baidu.rb +2 -3
- metadata +2 -2
data/bin/related_words
CHANGED
data/lib/related_words/baidu.rb
CHANGED
@@ -3,12 +3,11 @@ require 'cgi'
|
|
3
3
|
module RelatedWords
|
4
4
|
class Baidu
|
5
5
|
def self.query word
|
6
|
-
url = "http://
|
7
|
-
url = "http://m.baidu.com/s?word=#{CGI.escape word}"
|
6
|
+
url = "http://m.baidu.com/s?word=#{CGI.escape word}&ie=UTF-8"
|
8
7
|
response = Typhoeus.get url
|
9
8
|
if response.success?
|
10
9
|
text = response.body.match(/div class="bc relate">(.+?)<\/div>/)[1]
|
11
|
-
return text.scan(
|
10
|
+
return text.scan(/word=(.+?)\&/).flatten.collect{|r| CGI.unescape(r)}
|
12
11
|
else
|
13
12
|
return nil
|
14
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: related_words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2012-12-
|
12
|
+
date: 2012-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: fetch related words from baidu
|
15
15
|
email: 860577@gmail.com
|