epub_book 0.1.27 → 0.1.30
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 +19 -6
- data/lib/epub_book/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b033ca4e17804742f14f6e1acfe56a76af3bc90525bfc19a521e31c86bbbf3b4
|
4
|
+
data.tar.gz: 0ed53b49843e6ac92122f26d9362fe55ca141a39e6b190e378ae14363de7a9b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c1d96de6b8df5af9dee5181bd8bd4bcea4ea8a69d96ad0cce16ea3ff525f25ee37b44722c8bbd3dbfd79fb01bce521bbc9ddb2065b0aad5a4a5b1d1f350b8b
|
7
|
+
data.tar.gz: 5f0818cd97cfbc3971a46adcc50f871a033a4d008f38a3bbef3ef4f7b5a11c7c5d0098e91c46f7e9b29ff5e81c65309d6040d973c2df246e33126f6b0be62458
|
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,8 +205,14 @@ module EpubBook
|
|
198
205
|
else
|
199
206
|
txt_file.write("\n\n")
|
200
207
|
txt_file.write(item[:label])
|
201
|
-
txt_file.write("\n
|
202
|
-
|
208
|
+
txt_file.write("\n")
|
209
|
+
doc_file.css(@body_css).children.each do |it|
|
210
|
+
if it.name == 'text'
|
211
|
+
txt_file.write(it.text)
|
212
|
+
txt_file.write("\n")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
#txt_file.write(doc_file.css(@body_css).text)
|
203
216
|
end
|
204
217
|
rescue Exception => e
|
205
218
|
EpubBook.logger.info "Error:#{e.message},#{item.inspect}"
|
data/lib/epub_book/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- qmliu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -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
|