forked from captn3m0/cosmere-books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skyward.rb
33 lines (25 loc) · 779 Bytes
/
skyward.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true
require 'fileutils'
require 'nokogiri'
require_relative './methods'
FileUtils.mkdir_p('skyward')
BASE = 'https://www.getunderlined.com'
links = [
'/read/excerpt-reveal-start-reading-skyward-by-brandon-sanderson/'
]
episode = 1
links.each do |link|
url = BASE + link
puts "Download #{url}"
`curl --silent "#{url}" --output "skyward/#{episode}.html"` unless File.exist? "skyward/#{episode}.html"
episode += 1
end
html = '<title>Skyward</title>'
(1..(links.length)).each do |i|
complete_html = Nokogiri::HTML(open("skyward/#{i}.html"))
page = complete_html.css('article')[0]
html += page.inner_html
end
File.open('books/skyward.html', 'w') { |file| file.write(html) }
puts '[html] Generated HTML file'
generate('skyward', :all)