Created
April 19, 2021 14:55
-
-
Save igneus/d0a77f2a197ce18e9a1d0aeac852bdfe to your computer and use it in GitHub Desktop.
hymnologica.cz - check which Cantus IDs are available at CantusIndex
This file contains hidden or 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
# reads Cantus IDs on stdin, tries to fetch every one from CantusIndex, prints result | |
require 'mechanize' | |
def exists?(cantusid) | |
uri = "http://www.cantusindex.org/id/#{cantusid}" | |
agent = Mechanize.new | |
begin | |
agent.get uri | |
rescue Mechanize::ResponseCodeError | |
return false | |
end | |
true | |
end | |
ARGF.each do |cantusid| | |
cantusid.strip! | |
puts(cantusid + ',' + exists?(cantusid).to_s) | |
sleep 2 | |
end |
This file contains hidden or 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
# prints all sequence Cantus IDs available at hymnologica.cz | |
require 'mechanize' | |
uri = 'http://hymnologica.cz/sequences-ids' | |
agent = Mechanize.new | |
page = agent.get uri | |
page.parser.css('table.views-table tbody tr td:first').collect do |i| | |
puts i.text.strip | |
end |
This file contains hidden or 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
#!/bin/bash | |
ruby hymnologica_sequence_id_list.rb | ruby cantusindex_missing_ids.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment