Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created December 25, 2017 08:29
Show Gist options
  • Select an option

  • Save sonsongithub/42411b38d895ce60a2bb09fb40af7755 to your computer and use it in GitHub Desktop.

Select an option

Save sonsongithub/42411b38d895ce60a2bb09fb40af7755 to your computer and use it in GitHub Desktop.
amazon_parser.rb
fr = File.open("./booklist.txt", "r")
text = fr.read
a = text.scan(/注文の詳細注文日: (\d+)年(\d+)月(\d+)日.+\n(.+?)\n(.+?)\n販売: (.+?)\n/)
a.each{|e|
title = e[3].gsub("(Kindle 書籍 Kindle Books)", "")
year = e[0].to_i
month = e[1].to_i
day = e[2].to_i
date = sprintf("%04d/%02d/%02d", year, month, day)
if e[3] =~ /コミックス/
else
puts "#{date} #{title}"
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment