Skip to content

Instantly share code, notes, and snippets.

@hal99
Created June 30, 2011 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hal99/1056102 to your computer and use it in GitHub Desktop.
Save hal99/1056102 to your computer and use it in GitHub Desktop.
「ログ・ホライズン」を青空文庫形式のテキストファイルに変換する
require "rubygems"
require "open-uri"
require "nokogiri"
puts "ログ・ホライズン"
puts "橙乃ままれ"
puts "\n"
(1..54).each do |i|
puts %Q!\nThread #{sprintf("%03d",i)}\n\n!
doc = Nokogiri::HTML(open("http://ncode.syosetu.com/n8725k/#{i}/").read)
doc.xpath("//div[@id='novel_view']").inner_text.each do |line|
line = line.gsub( / /, '' ).gsub( /%/, '%' ) unless line.length == 0
puts line
end
sleep 10
end
@hal99
Copy link
Author

hal99 commented Jun 30, 2011

Ruby1.8.7で動かしています。スクリプトはただただしさんの「まおゆう」を青空文庫形式のテキストファイルに変換するからアイディアを頂きました。使い方は以下の通りで動作できると思います。PDFへの変換は、「青空キンドル」さんのサービスを利用しています。
$ ruby loghoraizun2aozora.rb > loghoraizun.txt
$ curl --data-urlencode text@loghoraizun.txt -d s=m -o loghoraizun.pdf http://a2k.aill.org/download.cgi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment