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

def scrape_details(url)
document = Nokogiri::HTML(open(url))

document.css('tbody tr').each do |row|
top_link = row.css('td.tonr a').first
top_id = top_link['href'][/TOLFDNR=(\d+)/, 1]
Expand All @@ -55,11 +54,14 @@ def scrape_calendar_data(year, month)
full_url = link ? "https://www.sitzungsdienst-schenefeld.de/bi/#{link}" : nil

if date_raw && full_url
# Neue Datumsformatierung
date_parts = date_raw.match(/([A-Za-z]+)\s+(\d+)/)
formatted_date = "#{date_parts[1]}, #{date_parts[2].rjust(2, '0')}.#{month.to_s.rjust(2, '0')}.#{year}"
puts "Datum: #{formatted_date}, URL: #{full_url}"
scrape_details(full_url)
if date_parts
formatted_date = "#{date_parts[1]}, #{date_parts[2].rjust(2, '0')}.#{month.to_s.rjust(2, '0')}.#{year}"
puts "Datum: #{formatted_date}, URL: #{full_url}"
scrape_details(full_url)
else
puts "Datum konnte nicht verarbeitet werden: #{date_raw}"
end
end
end
end
Expand Down

0 comments on commit 39de400

Please sign in to comment.