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

def scrape_calendar_data(year, month)
url = "https://www.sitzungsdienst-schenefeld.de/bi/si010_r.asp?MM=#{month}&YY=#{year}"
puts "Attempting to access URL: #{url}"
begin
document = Nokogiri::HTML(open(url))
document.css('a[href*="si010_r.asp?DD="]').each do |link|
document = Nokogiri::HTML(URI.open(url))
puts "Page loaded successfully."
links_found = document.css('a[href*="si010_r.asp?DD="]')
puts "Number of matching links found: #{links_found.count}"
links_found.each do |link|
day = link['href'][/DD=(\d+)/, 1]
month = link['href'][/MM=(\d+)/, 1]
year = link['href'][/YY=(\d+)/, 1]
Expand All @@ -43,5 +46,5 @@ def scrape_calendar_data(year, month)
end
end

# Test the function with a specific month and year
scrape_calendar_data(2024, 3)

0 comments on commit 99c804c

Please sign in to comment.