7 require "rexml/document"
18 puts "This is going to take a while...."
21 doc = open("http://irspy.indexdata.com/find.html?cql.anywhere=&dc.title=&zeerex.country=&net.protocol=z39.50&net.host=&net.port=&net.path=&zeerex.libType=&dc.description=&dc.creator=&_sort=&_search=Search&_count=#{m}&_skip=#{m-20}"){
24 #fields = doc.search(/"//a[@title='Raw XML record']")
25 #fields = doc.search("//a")
29 (doc/"//a[@title='Raw XML record']").each do |link|
30 xml_address = "http://irspy.indexdata.com" + link.attributes['href']
32 file = Net::HTTP.get(URI.parse(xml_address))
36 full_xml = "<root>" + all_xml.join("\n") + "</root>"
40 xml_doc = REXML::Document.new full_xml
44 File.open("irspy#{i}.xml", "w") do |f|
46 puts "written to file"
55 records = xml_doc.elements.to_a("//explain")
61 records.each do | rec |
63 all_recs = File.new("irspy_all.txt","w+")
69 puts rec.elements["databaseInfo/title"].text
70 if rec.elements["databaseInfo/title"]
71 puts "Looking in #{rec.elements["databaseInfo/title"].text} ..."
75 if rec.elements ["recordInfo/recordSyntax[@name='xml']"]
76 #.attributes["recodSyntax"]
77 #puts rec.elements["recordInfo/recordSyntax[@name='xml']"]
79 if rec.elements ["serverInfo[@protocol='Z39.50']"]
80 puts "we've got a match!"
84 rec.elements.each("irspy:status/irspy:probe") do | elem |
87 a << elem.attributes["ok"]
94 line = "- [" + rec.elements["serverInfo/host"].text + "," +
95 rec.elements["serverInfo/port"].text + "," +
96 rec.elements["serverInfo/database"].text
97 + "] #" + rec.elements["databaseInfo/title"].text
109 aFile = File.new("irspy.txt","w+")
110 aFile.write(all_lines)