epub_book 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epub_book/book.rb +10 -3
- data/lib/epub_book/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd8a0433b5b28cbafc6bdd278240eebf5bff4a80
|
4
|
+
data.tar.gz: 64228d14dee44467a4e4f9bbbaeb00c9b708596d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d7dc626ff49c8bb275de0559025d23c77374cc8c17887e4b08da219f5500b4d59e015965edb0ac86ee3779ef6f356550a42b323c78e771981d0e628e19fbfb
|
7
|
+
data.tar.gz: 6f2db1d7ba8edd0a12c73bb7ef8e02e7897cec35b1af5f2a858456f7c602d1bc97d8d9e85bb67fe5c68cc73f7c0480cfd91ee0c225f060c4226157da143dca07
|
data/lib/epub_book/book.rb
CHANGED
@@ -110,11 +110,17 @@ module EpubBook
|
|
110
110
|
#得到书目索引
|
111
111
|
def fetch_index(url=nil)
|
112
112
|
url ||= @index_url
|
113
|
-
|
113
|
+
_tmp_string = open(URI.encode(url),"User-Agent" => @user_agent ,'Referer'=> @referer).read
|
114
|
+
doc = Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
|
114
115
|
#generate index.yml
|
115
116
|
|
116
117
|
if !book[:title]
|
117
|
-
doc1 = @des_url.nil?
|
118
|
+
doc1 = if @des_url.nil?
|
119
|
+
doc
|
120
|
+
else
|
121
|
+
_tmp_string = open(URI.encode(@des_url),"User-Agent" => @user_agent ,'Referer'=> @referer).read
|
122
|
+
Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
|
123
|
+
end
|
118
124
|
get_des(doc1)
|
119
125
|
end
|
120
126
|
|
@@ -152,7 +158,8 @@ module EpubBook
|
|
152
158
|
next if test(?s,content_path)
|
153
159
|
|
154
160
|
begin
|
155
|
-
|
161
|
+
_tmp_string = open(item[:url],"User-Agent" => @user_agent,'Referer'=> @referer).read
|
162
|
+
doc_file = Nokogiri::HTML(Encoding::UTF_8 === _tmp_string.encoding ? _tmp_string : _tmp_string.force_encoding('gbk').encode('utf-8'))
|
156
163
|
|
157
164
|
File.open(content_path,'w') do |f|
|
158
165
|
f.write("<h3>#{item[:label]}</h3>")
|
data/lib/epub_book/version.rb
CHANGED