Last active
December 9, 2016 20:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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