Class: DMMCrawler::Ranking
- Inherits:
-
Object
- Object
- DMMCrawler::Ranking
- Defined in:
- lib/dmm-crawler/ranking.rb
Instance Method Summary collapse
- #arts ⇒ Object
-
#initialize(arguments) ⇒ Ranking
constructor
A new instance of Ranking.
Constructor Details
#initialize(arguments) ⇒ Ranking
Returns a new instance of Ranking.
3 4 5 6 7 8 |
# File 'lib/dmm-crawler/ranking.rb', line 3 def initialize(arguments) @agent = discriminate_agent(arguments[:agent]) @term = discriminate_term(arguments[:term]) @submedia = arguments[:submedia] @url = File.join(BASE_URL, "/dc/doujin/-/ranking-all/=/sort=popular/submedia=#{@submedia}/term=#{@term}") end |
Instance Method Details
#arts ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dmm-crawler/ranking.rb', line 10 def arts arts = page.search('.rank-rankListItem.fn-setPurchaseChange').take(10).map do |element| sleep_each do url = File.join(BASE_URL, element.search('.rank-name a').first.attributes['href'].value) Attributes.new(url).to_a end end arts.map.with_index(1) do |(title, title_link, image_url, submedia, , informations, ), rank| { title: "#{rank}位: #{title}", title_link: title_link, image_url: image_url, submedia: submedia, author: , informations: informations, tags: } end end |