iciba 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fy +2 -1
- data/lib/iciba/fanyi.rb +1 -1
- data/lib/iciba/version.rb +1 -1
- metadata +1 -1
data/bin/fy
CHANGED
@@ -6,11 +6,12 @@ require 'readability'
|
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
8
|
$links = false
|
9
|
+
$extended = true
|
9
10
|
|
10
11
|
OptionParser.new do |opts|
|
11
12
|
opts.banner = "Usage: #{File.basename($0)} ('words'|word)"
|
12
13
|
opts.on("-l", "--links", "Download links?") { |b| $links = true }
|
13
|
-
opts.on("-
|
14
|
+
opts.on("-s", "--single", "Single word") { |b| $extended = false }
|
14
15
|
opts.on("-p", "--pinyin", "Pinyin") { |b| $pinyin = true }
|
15
16
|
opts.on("-o", "--open", "go to fy.iciba.com") { |b| $pinyin = true }
|
16
17
|
opts.on("-h", "--help", "Print") do
|
data/lib/iciba/fanyi.rb
CHANGED
@@ -45,7 +45,7 @@ module Iciba
|
|
45
45
|
|
46
46
|
def download_and_parse(words, dir, extended)
|
47
47
|
self.response = Iciba::Tools.parse(Iciba::Tools.post('http://fy.iciba.com/api.php', {:q => words, :type => dir}).body_str)
|
48
|
-
self.html = self.response.ret.
|
48
|
+
self.html = self.response.ret.encode("UTF-8")
|
49
49
|
self.result = (Iciba::Tools.doc(self.html)/'span.dd').text.strip
|
50
50
|
self.result = self.html if self.result == ""
|
51
51
|
self.result = self.result.split(',')[0] if self.result.include?(',') unless extended
|
data/lib/iciba/version.rb
CHANGED