Skip to content

Instantly share code, notes, and snippets.

@toroidal-code
Last active May 3, 2018 20:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toroidal-code/6415977 to your computer and use it in GitHub Desktop.
Save toroidal-code/6415977 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python2
from PyZ3950 import zoom # ZOOM is the protocol
from pymarc import MARCReader # This is for easily dealing with USMARC data
from pyx import * # This is for exporting EPS/PDF
import os # for calling lpr
unit.set(xscale=1.5) # Text scale for pyx
conn = zoom.Connection('z3950.loc.gov', 7090) # Which server to connect to with ZOOM #albert.rit.edu, 210
conn.databaseName = 'VOYAGER' # Which database to use #innopac
conn.preferredRecordSyntax = 'USMARC' # Has to be one of available database record emissions
while True: # main loop
i = raw_input(">> ") # grab input
query = zoom.Query('CCL', str(i)) # send query with input
for item in conn.search(query): # iterator for query results
for rec in MARCReader(item.data): # iterator for records in result
try: # python blows up if the rec['050'] record isn't accessible
print rec.title() # print title for verification
print rec['050']['a']
#ans = raw_input("Is this right? (y/n)")
#if ans.lower() == 'y':
c = canvas.canvas()
c.text(0.65, 0, rec['050']['a'], [text.halign.boxcenter, trafo.rotate(-90)])
c.text(0, 0, rec['050']['b'], [text.halign.boxcenter, trafo.rotate(-90)])
c.writePDFfile()
os.system("lpr isbn2.pdf")
except TypeError:
print "Whoops"
#!/usr/bin/env ruby
require 'nokogiri'
require 'csv'
doc = Nokogiri::HTML(`curl http://isbnsearch.sourceforge.net/servers.html`)
csv = CSV.open("output.csv", 'w')
doc.xpath('//table//tr').each do |row|
tarray = [] #temporary array
row.xpath('td').each do |cell|
tarray << cell.text #Build array of that row of data.
end
csv << tarray #Write that row out to csv file
end
csv.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment