Class: Ietf::Data::Importer::Scrapers::BaseScraper
- Inherits:
-
Object
- Object
- Ietf::Data::Importer::Scrapers::BaseScraper
- Defined in:
- lib/ietf/data/importer/scrapers/base_scraper.rb
Overview
Base class for web scrapers
Direct Known Subclasses
Instance Method Summary collapse
-
#fetch_html(url) ⇒ Nokogiri::HTML::Document
Fetch HTML content from a URL and parse it with Nokogiri.
-
#log(message, level = 0) ⇒ Object
Log a message with indentation.
Instance Method Details
#fetch_html(url) ⇒ Nokogiri::HTML::Document
Fetch HTML content from a URL and parse it with Nokogiri
15 16 17 18 19 20 |
# File 'lib/ietf/data/importer/scrapers/base_scraper.rb', line 15 def fetch_html(url) Nokogiri::HTML(URI.open(url)) rescue => e puts " Error fetching URL #{url}: #{e.}" nil end |
#log(message, level = 0) ⇒ Object
Log a message with indentation
25 26 27 28 |
# File 'lib/ietf/data/importer/scrapers/base_scraper.rb', line 25 def log(, level = 0) indent = " " * level puts "#{indent}#{}" end |