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 22, 2024
1 parent dc8efb6 commit 3e3d854
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ def scrape_vorlagen_details(vorlagen_url)
vorlagenbezeichnung = vorlagenbezeichnung_element ? vorlagenbezeichnung_element.text.strip : "Keine Vorlagenbezeichnung gefunden"
puts "Vorlagenbezeichnung: #{vorlagenbezeichnung}"

# Extrahieren des gesamten Texts von mainContent
# Extrahieren und Bereinigen des gesamten Texts von mainContent
vorlagenprotokolltext_element = document.at_css('#mainContent')
vorlagenprotokolltext = vorlagenprotokolltext_element ? vorlagenprotokolltext_element.inner_text.strip : "Kein Text im Hauptinhalt gefunden"
if vorlagenprotokolltext_element
vorlagenprotokolltext = vorlagenprotokolltext_element.text
vorlagenprotokolltext = vorlagenprotokolltext.gsub(/\s+/, ' ').strip # Ersetzt mehrfache Leerzeichen durch ein einzelnes und entfernt führende/anhängende Leerzeichen
vorlagenprotokolltext = vorlagenprotokolltext.gsub(/(?:\r?\n|\r)+/, ' ') # Ersetzt neue Zeilen durch ein Leerzeichen, um Text kompakter zu machen
else
vorlagenprotokolltext = "Kein Text im Hauptinhalt gefunden"
end
puts "Vorlagenprotokolltext: #{vorlagenprotokolltext}"
end

Expand All @@ -63,3 +69,4 @@ def scrape_vorlagen_details(vorlagen_url)




0 comments on commit 3e3d854

Please sign in to comment.