Skip to content

Commit

Permalink
Update scraper.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
BfB-Schenefeld committed Apr 21, 2024
1 parent 908f7d1 commit 0b60a2f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
# called "data.sqlite" in the current working directory which has at least a table
# called "data".
require 'open-uri'
require 'nokogiri'

def simple_test
def simple_scrape
url = "https://www.example.com"
begin
content = open(url).read
puts "Successfully retrieved content from #{url}"
html = open(url)
doc = Nokogiri::HTML(html)
title = doc.at_css('title').text
puts "Title of the page is: #{title}"
rescue StandardError => e
puts "Error during request: #{e.message}"
puts "Error during scraping: #{e.message}"
end
end

simple_test
simple_scrape

0 comments on commit 0b60a2f

Please sign in to comment.