Class: DoctorScrape::Search
- Inherits:
-
Object
- Object
- DoctorScrape::Search
- Defined in:
- lib/doctor_scrape/search.rb
Class Method Summary collapse
Class Method Details
.nora(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/doctor_scrape/search.rb', line 9 def nora(={}) params = { "PAGESIZE" => [:limit] || 50, "FROM" => [:from] || 2007, "TO" => [:to] || Time.now.year, "SEARCHMODE" => "TOPIC", "DOCUMENTTYPES" => "Doctoral+thesis", "RESULTMODE" => "rss", } url = "http://www.ub.uio.no/nora/result.html?" << params.map { |key,val| "#{key}=#{val}" }.join("&") open url do |rss| feed = RSS::Parser.parse rss return [] if feed.nil? items = feed.items.map &:link [:resolve] ? resolve_scrapers(items) : items end end |
.resolve_scrapers(urls) ⇒ Object
35 36 37 |
# File 'lib/doctor_scrape/search.rb', line 35 def resolve_scrapers(urls) resolve_urls(urls).map { |url| Scraper.for url } end |
.resolve_urls(urls) ⇒ Object
31 32 33 |
# File 'lib/doctor_scrape/search.rb', line 31 def resolve_urls(urls) urls.map { |url| Unwind::RedirectFollower.resolve(url).final_url } end |