class NyaaScraper
Attributes
base[RW]
Public Class Methods
new(search)
click to toggle source
# File lib/nyaa_scraper.rb, line 8 def initialize(search) @search = search self.base = "https://nyaa.si" end
Public Instance Methods
html()
click to toggle source
# File lib/nyaa_scraper.rb, line 17 def html uri.read end
links()
click to toggle source
# File lib/nyaa_scraper.rb, line 21 def links Nokogiri::HTML(html)\ .css(".torrent-list tr a") \ .map { |link| link["href"] } end
magnets()
click to toggle source
# File lib/nyaa_scraper.rb, line 27 def magnets links.select { |href| href =~ /^magnet/ } end
torrents()
click to toggle source
# File lib/nyaa_scraper.rb, line 31 def torrents links.select { |href| href =~ /\.torrent$/ } \ .map { |href| URI.join self.base, "#{href}" } \ .map { |uri| uri.to_s } end
uri()
click to toggle source
# File lib/nyaa_scraper.rb, line 13 def uri URI.join self.base, "?#{@search.querystring}" end