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

Parameters:

  • hit (Hash)

Returns:

  • (Hash)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/relaton_iso/scrapper.rb', line 52

def parse_page(hit_data)
  return unless hit_data["path"] =~ /\d+$/

  doc, url = get_page "/standard/#{hit_data['path'].match(/\d+$/)}.html"

  # 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(doc),
    edition: edition,
    language: langs(doc).map { |l| l[:lang] },
    script: langs(doc).map { |l| script(l[:lang]) }.uniq,
    titles: titles,
    type: fetch_type(hit_data["title"]),
    docstatus: fetch_status(doc, hit_data["status"]),
    ics: fetch_ics(doc),
    dates: fetch_dates(doc),
    contributors: fetch_contributors(hit_data["title"]),
    editorialgroup: fetch_workgroup(doc),
    abstract: abstract,
    copyright: fetch_copyright(hit_data["title"], doc),
    link: fetch_link(doc, url),
    relations: fetch_relations(doc),
    structuredidentifier: fetch_structuredidentifier(doc),
  )
end