Sha256: 79907aeda515749c7dd759df69adbb9878ac6e33c29f3ef3ef4a24facd0eed54
Contents?: true
Size: 685 Bytes
Versions: 2
Compression:
Stored size: 685 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 language not found 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iev-0.2.6 | lib/iev.rb |
iev-0.2.5 | lib/iev.rb |