Module: RelatonCie::Scrapper
- Defined in:
- lib/relaton_cie/scrapper.rb
Constant Summary collapse
- ENDPOINT =
"https://raw.githubusercontent.com/relaton/relaton-data-cie/main/".freeze
- INDEX_FILE =
"index-v1.yaml".freeze
Class Method Summary collapse
Class Method Details
.scrape_page(code) ⇒ RelatonCie::BibliographicItem
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/relaton_cie/scrapper.rb', line 9 def scrape_page(code) index = Relaton::Index.find_or_create :cie, url: "#{ENDPOINT}index-v1.zip", file: INDEX_FILE row = index.search(code).min_by { |r| r[:id] } return unless row parse_page "#{ENDPOINT}#{row[:file]}" rescue OpenURI::HTTPError => e return if e.io.status.first == "404" raise RelatonBib::RequestError, "No document found for #{code} reference. #{e.}" end |