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 b7bf23a commit 004fc65
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# called "data".
require 'nokogiri'
require 'open-uri'
require 'date'

def scrape_details(url)
document = Nokogiri::HTML(open(url))
Expand All @@ -49,13 +50,12 @@ def scrape_calendar_data(year, month)
document = Nokogiri::HTML(open(url))

document.css('span#sidatum a').each do |link|
date_raw = link.text.strip
if date_raw
formatted_date = Date.parse(date_raw).strftime("%a, %d.%m.%Y")
puts "Datum: #{formatted_date}, URL: #{link['href']}"
date_text = link.text.strip
if date_text.match?(/\A\w{2}, \d{2}\.\d{2}\.\d{4}\z/)
puts "Datum: #{date_text}, URL: https://www.sitzungsdienst-schenefeld.de/bi/#{link['href']}"
scrape_details("https://www.sitzungsdienst-schenefeld.de/bi/#{link['href']}")
else
puts "Datum konnte nicht verarbeitet werden: #{date_raw}"
puts "Datum konnte nicht verarbeitet werden: #{date_text}"
end
end
end
Expand All @@ -65,3 +65,4 @@ def scrape_calendar_data(year, month)




0 comments on commit 004fc65

Please sign in to comment.