iciba 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -0
- data/bin/fy +2 -1
- data/lib/iciba/fanyi.rb +1 -1
- data/lib/iciba/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
data/bin/fy
CHANGED
@@ -39,8 +39,9 @@ regex = /https?:\/\/[\S]+/
|
|
39
39
|
links = ARGV.first.scan(regex)
|
40
40
|
|
41
41
|
def loop_through_links(links)
|
42
|
+
puts links.inspect
|
42
43
|
links.each do |l|
|
43
|
-
text = Readability::Document.new(Iciba::Tools.download(l)).content.gsub('<p>', '').gsub('</p>', "\r\n").gsub('</div></div>', '').gsub('<div><div>', '')
|
44
|
+
text = Readability::Document.new(Iciba::Tools.download(l).force_encoding("UTF-8")).content.gsub('<p>', '').gsub('</p>', "\r\n").gsub('</div></div>', '').gsub('<div><div>', '')
|
44
45
|
puts wrap_text(text) unless text == ''
|
45
46
|
puts '------------------------------------------------------------------------------------' unless text == ''
|
46
47
|
end
|
data/lib/iciba/fanyi.rb
CHANGED
@@ -24,7 +24,7 @@ module Iciba
|
|
24
24
|
|
25
25
|
def download_and_parse(words, dir, extended)
|
26
26
|
self.response = Iciba::Tools.parse(Iciba::Tools.post('http://fy.iciba.com/api.php', {:q => words, :type => dir}).body_str)
|
27
|
-
self.html = self.response.ret
|
27
|
+
self.html = self.response.ret.force_encoding("UTF-8")
|
28
28
|
self.result = (Iciba::Tools.doc(self.html)/'span.dd').text.strip
|
29
29
|
self.result = self.html if self.result == ""
|
30
30
|
self.result = self.result.split(',')[0] if self.result.include?(',') unless extended
|
data/lib/iciba/version.rb
CHANGED