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 1c171fe commit 6bda819
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,7 +25,6 @@
# called "data".
require 'nokogiri'
require 'open-uri'
require 'date'

def scrape_details(url)
full_url = "https://www.sitzungsdienst-schenefeld.de/bi/#{url}"
Expand All @@ -50,11 +49,14 @@ def scrape_calendar_data(year, month)
url = "https://www.sitzungsdienst-schenefeld.de/bi/si010_r.asp?MM=#{month}&YY=#{year}"
document = Nokogiri::HTML(open(url))

date_link_element = document.at_css('span#sidatum a')
if date_link_element && date_link_element['href']
scrape_details(date_link_element['href'])
else
puts "Kein Datum-Link gefunden oder 'href'-Attribut fehlt."
# Datum direkt aus dem Link extrahieren
document.css('a[href*="si010_r.asp?DD="]').each do |link|
day = link['href'][/DD=(\d+)/, 1]
month = link['href'][/MM=(\d+)/, 1]
year = link['href'][/YY=(\d+)/, 1]
formatted_date = "#{day}.#{month}.#{year}"
puts "Datum: #{formatted_date}, URL: #{link['href']}"
scrape_details(link['href'])
end
end

Expand Down

0 comments on commit 6bda819

Please sign in to comment.