Module: RelatonIso::Scrapper

Defined in:
lib/relaton_iso/scrapper.rb

Overview

Scrapper. rubocop:disable Metrics/ModuleLength

Constant Summary collapse

DOMAIN =
"https://www.iso.org"
TYPES =
{
  "TS" => "technical-specification",
  "TR" => "technical-report",
  "PAS" => "publicly-available-specification",
  # "AWI" => "approvedWorkItem",
  # "CD" => "committeeDraft",
  # "FDIS" => "finalDraftInternationalStandard",
  # "NP" => "newProposal",
  # "DIS" => "draftInternationalStandard",
  # "WD" => "workingDraft",
  # "R" => "recommendation",
  "Guide" => "guide",
}.freeze

Class Method Summary collapse

Class Method Details

.parse_page(hit_data) ⇒ Hash

Parse page. rubocop:disable Metrics/AbcSize, Metrics/MethodLength



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/relaton_iso/scrapper.rb', line 33

def parse_page(hit_data)
  path = "/contents/data/standard#{hit_data["splitPath"]}/#{hit_data["csnumber"]}.html"
  doc, url = get_page path

  # Fetch edition.
  edition = doc&.xpath("//strong[contains(text(), 'Edition')]/..")&.
    children&.last&.text&.match(/\d+/)&.to_s

  titles, abstract = fetch_titles_abstract(doc)

  RelatonIsoBib::IsoBibliographicItem.new(
    fetched: Date.today.to_s,
    docid: fetch_docid(hit_data["docRef"]),
    docnumber: fetch_docnumber(doc),
    edition: edition,
    language: langs(doc).map { |l| l[:lang] },
    script: langs(doc).map { |l| script(l[:lang]) }.uniq,
    title: titles,
    doctype: fetch_type(hit_data["docRef"]),
    docstatus: fetch_status(doc),
    ics: fetch_ics(doc),
    date: fetch_dates(doc, hit_data["docRef"]),
    contributor: fetch_contributors(hit_data["docRef"]),
    editorialgroup: fetch_workgroup(doc),
    abstract: abstract,
    copyright: fetch_copyright(hit_data["docRef"], doc),
    link: fetch_link(doc, url),
    relation: fetch_relations(doc),
    structuredidentifier: fetch_structuredidentifier(doc),
  )
end