Skip to content

Instantly share code, notes, and snippets.

@Fensterbank
Last active December 9, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fensterbank/894008846792f9cae01a09ba8b50663d to your computer and use it in GitHub Desktop.
Save Fensterbank/894008846792f9cae01a09ba8b50663d to your computer and use it in GitHub Desktop.
Downloads the newest edition of the parish newsletter 's Blättle from the city of Metzingen
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'date'
puts "#{DateTime.now.strftime("%F %T")} 's Blättle Downloader 1.0.0"
doc = Nokogiri::HTML(open('https://www.metzingen.de/de/Stadt+B%C3%BCrger/Aktuelles/Mitteilungsblatt'))
doc.css('.multiList li:first a').each do |link|
puts "#{DateTime.now.strftime("%F %T")} Aktueller Eintrag ist #{link.attributes['title'].value}"
target_filepath = "ausgaben/#{link.content.gsub(/'s/, 's')}.pdf"
unless File.file?(target_filepath)
puts "#{DateTime.now.strftime("%F %T")} Neue Ausgabe wird heruntergeladen..."
`wget -O "#{target_filepath}" #{link.attributes['href'].value}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment