35 lines
711 B
Python
35 lines
711 B
Python
from xml.dom import minidom
|
|
from PyZ3950 import zoom
|
|
|
|
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
|
|
|
|
class Bibsys():
|
|
def __init__(self):
|
|
self.conn = zoom.Connection ('z3950.bibsys.no', 2100)
|
|
self.conn.databaseName = 'BIBSYS'
|
|
self.conn.preferredRecordSyntax = 'XML'
|
|
|
|
def isbn_search(self, isbn):
|
|
query = zoom.Query('CCL', 'ISBN='+isbn)
|
|
result = self.conn.search(query)
|
|
return result
|
|
|
|
def close(self):
|
|
self.conn.close()
|
|
|
|
#class Menu():
|
|
|
|
def get_book_loop():
|
|
bib = Bibsys()
|
|
while True:
|
|
input = raw_input('Enter ISBN number> ')
|
|
if input in exit_commands:
|
|
break
|
|
else:
|
|
r = bib.isbn_search(input)
|
|
if len(r) > 0:
|
|
print r[0]
|
|
bib.close()
|
|
|
|
get_book_loop()
|