Sha256: 25aa61500053b6305759e184f3f29ddd9b0adb53437deb6fbe9637826bb6ef2c
Contents?: true
Size: 662 Bytes
Versions: 7
Compression:
Stored size: 662 Bytes
Contents
require "iev/version" require "iev/db" require "open-uri" require "nokogiri" module Iev # # Scrape Electropedia for term. # # @param [String] code for example "103-01-02" # @param [String] lang language code, for examle "en" # # @return [String, nil] if found than term, if code not found then empty string, # if langguage not fiund then nil. # def self.get(code, lang) url = "http://www.electropedia.org/iev/iev.nsf/display?openform&ievref=#{code}" doc = Nokogiri::HTML OpenURI.open_uri(url), nil, "UTF-8" xpath = "//table/tr/td/div/font[.=\"#{lang}\"]/../../following-sibling::td[2]" doc.at(xpath)&.text&.strip end end
Version data entries
7 entries across 7 versions & 2 rubygems