Class: Ruboty::DMM::Ranking
- Inherits:
-
Object
- Object
- Ruboty::DMM::Ranking
- Defined in:
- lib/ruboty/dmm/ranking.rb
Constant Summary collapse
- BASE_URL =
'http://www.dmm.co.jp'.freeze
- RANKING_URL =
def initialize(arguments) @term = discriminate_term(arguments[:term]) @submedia = discriminate_submedia(arguments[:submedia]) @url = "#{BASE_URL}/dc/doujin/-/ranking-all/=/sort=popular/submedia=#{@submedia}/term=#{@term}" @agent = Agent.new.agent end
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruboty/dmm/ranking.rb', line 14 def call books = page.search('.rank-rankListItem.fn-setPurchaseChange').map do |element| [ element.search('.rank-name').first.text.strip, "#{BASE_URL}#{element.search('.rank-name').first.search('a').first.attributes.first[1].value}" ] end ranking = books.take(10).map.with_index(1) { |book, index| "#{index}位\nタイトル: #{book.first}\nURL: #{book.last}" } ranking.join("\n\n") end |