51
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

で、オライリー本を全冊購入するといくらなのか

Last updated at Posted at 2015-08-03

オライリー・ジャパンの書籍380冊、全部買った
という記事が話題になってましたが、合計金額がなかったので調べました。

oreilly.rb
require 'open-uri'
require 'nokogiri'

open("http://www.oreilly.co.jp/catalog/") do |f|
  doc = Nokogiri::HTML.parse f.read
  prices = doc.css(".price").map{|p| p.text.tr(?,, '').to_i }
  amount = prices.inject(:+).to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/, '\1,')

  puts "合計 #{prices.size}#{amount}円"
end
結果
合計 419冊 1,442,556円

全巻一括購入で割引とかあるんでしょうか。分かりません。

てか、ブログの記事より40冊ほど多いですね。
ざっくり一冊平均3442円なので380冊で130万8318円ぐらいでしょうか。

51
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
51
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?