Class: DMMCrawler::Ranking::DojinRanking
- Inherits:
-
BaseRanking
- Object
- BaseRanking
- DMMCrawler::Ranking::DojinRanking
- Includes:
- Attributes
- Defined in:
- lib/dmm-crawler/ranking/dojin_ranking.rb
Constant Summary collapse
- FETCHING_LIMITATION =
10
Instance Method Summary collapse
- #arts ⇒ Object
-
#initialize(agent:, submedia: nil, term: nil) ⇒ DojinRanking
constructor
A new instance of DojinRanking.
Constructor Details
#initialize(agent:, submedia: nil, term: nil) ⇒ DojinRanking
Returns a new instance of DojinRanking.
10 11 12 13 14 15 |
# File 'lib/dmm-crawler/ranking/dojin_ranking.rb', line 10 def initialize(agent:, submedia: nil, term: nil) @agent = discriminate_agent(agent) @submedia = submedia @term = term @url = File.join(BASE_URL, "/dc/doujin/-/ranking-all/=/sort=popular/submedia=#{@submedia}/term=#{@term}") end |
Instance Method Details
#arts ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dmm-crawler/ranking/dojin_ranking.rb', line 17 def arts arts = page.search('.rank-rankListItem.fn-setPurchaseChange').take(FETCHING_LIMITATION).map do |element| sleep_each do url = File.join(BASE_URL, element.search('.rank-name a').first.attributes['href'].value) DojinAttributes.new(url, agent: @agent).to_a end end arts.map.with_index(1) do |(title, title_link, image_url, submedia, , price, affiliateable, ), rank| { title: title, title_link: title_link, image_url: image_url, submedia: submedia, author: , rank: rank, price: price, affiliateable: affiliateable, tags: } end end |