epub_book 0.1.29 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/epub_book.gemspec +1 -1
- data/lib/epub_book/book.rb +11 -5
- data/lib/epub_book/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0f6cc5fbf1059d26d9fb9268e23bb13c2d9c1b1ab83147c007c14e4566708d
|
4
|
+
data.tar.gz: f24f55e0f154ba6415f200d6aef97ad661470b878d3df0d78d34865a48ca6e8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d2fe057e0f4883be7606b041b52ade0188d759c87c4bbf43ffafff1d1ca01f9c3bdc44982f0e83861b2c937bb351af12e2ed39a48e70cebbe39ae81ca685b7e
|
7
|
+
data.tar.gz: ddb8bf3aa0ce7314f30a917be50f8b7d38dfdea61d316fa8be9a8f10695726f82d6c04ec42c6a1a60e725a30e47fa7744ac995a15e3f5684ad907bd470c02e99
|
data/epub_book.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency 'http','~> 5.0', '>= 5.0.4'
|
31
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.
|
31
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.12', '>= 1.12.4'
|
32
32
|
spec.add_dependency 'eeepub', '~> 0.8.1'
|
33
33
|
spec.add_dependency 'zip-zip', '~> 0.3'
|
34
34
|
spec.add_dependency 'mail', '~>2.7.0'
|
data/lib/epub_book/book.rb
CHANGED
@@ -126,7 +126,8 @@ module EpubBook
|
|
126
126
|
def fetch_index(url=nil)
|
127
127
|
book[:files] = []
|
128
128
|
url ||= @index_url
|
129
|
-
doc = Nokogiri::HTML(judge_encoding(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(url).to_s))
|
129
|
+
#doc = Nokogiri::HTML(judge_encoding(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(url).to_s))
|
130
|
+
doc = Nokogiri::HTML(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(url).to_s)
|
130
131
|
#generate index.yml
|
131
132
|
EpubBook.logger.info "------Fetch index--#{url}---------------"
|
132
133
|
|
@@ -134,18 +135,24 @@ module EpubBook
|
|
134
135
|
doc1 = if @des_url.nil?
|
135
136
|
doc
|
136
137
|
else
|
137
|
-
Nokogiri::HTML(judge_encoding(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(generate_abs_url(doc.css(@des_url).attr("href").to_s)).to_s))
|
138
|
+
#Nokogiri::HTML(judge_encoding(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(generate_abs_url(doc.css(@des_url).attr("href").to_s)).to_s))
|
139
|
+
Nokogiri::HTML(HTTP.headers("User-Agent" => @user_agent ,'Referer'=> @referer).get(generate_abs_url(doc.css(@des_url).attr("href").to_s)).to_s)
|
138
140
|
end
|
139
141
|
get_des(doc1)
|
140
142
|
end
|
141
143
|
|
142
144
|
#binding.pry
|
145
|
+
#EpubBook.logger.info @index_item_css
|
146
|
+
|
143
147
|
doc.css(@index_item_css).each do |item|
|
144
148
|
_href = item.attr(@item_attr).to_s
|
145
149
|
next if _href.start_with?('javascript') || _href.start_with?('#')
|
146
150
|
|
147
151
|
_href = generate_abs_url(_href)
|
148
152
|
|
153
|
+
#EpubBook.logger.info item.inspect
|
154
|
+
#EpubBook.logger.info item.text
|
155
|
+
|
149
156
|
book[:files] << {label: item.text, url: _href}
|
150
157
|
end
|
151
158
|
|
@@ -186,7 +193,7 @@ module EpubBook
|
|
186
193
|
next if test(?s,content_path)
|
187
194
|
|
188
195
|
begin
|
189
|
-
doc_file = Nokogiri::HTML(
|
196
|
+
doc_file = Nokogiri::HTML(HTTP.headers("User-Agent" => @user_agent,'Referer'=> @referer).get(item[:url]).to_s)
|
190
197
|
|
191
198
|
EpubBook.logger.info item[:label]
|
192
199
|
#binding.pry
|
@@ -198,11 +205,10 @@ module EpubBook
|
|
198
205
|
else
|
199
206
|
txt_file.write("\n\n")
|
200
207
|
txt_file.write(item[:label])
|
201
|
-
txt_file.write("\n")
|
208
|
+
txt_file.write("\n\n")
|
202
209
|
doc_file.css(@body_css).children.each do |it|
|
203
210
|
if it.name == 'text'
|
204
211
|
txt_file.write(it.text)
|
205
|
-
txt_file.write("\n")
|
206
212
|
end
|
207
213
|
end
|
208
214
|
#txt_file.write(doc_file.css(@body_css).text)
|
data/lib/epub_book/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epub_book
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qmliu
|
@@ -36,20 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1.
|
39
|
+
version: '1.12'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 1.12.4
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
49
|
+
version: '1.12'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.
|
52
|
+
version: 1.12.4
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: eeepub
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|