summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2012-02-12 11:47:32 +0100
committerFlorian Bruhin <me@the-compiler.org>2012-02-12 11:47:32 +0100
commit2c3f2d8270f520cda9e733ff642cdd71dd6f3ee3 (patch)
tree5e314e2172ea4eeb4b5da90da056c1f331b77be3
downloadwebopac-2c3f2d8270f520cda9e733ff642cdd71dd6f3ee3.tar.gz
webopac-2c3f2d8270f520cda9e733ff642cdd71dd6f3ee3.zip
I feel like I should start using git here
-rw-r--r--webopac.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/webopac.py b/webopac.py
new file mode 100644
index 0000000..f608793
--- /dev/null
+++ b/webopac.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+import http.cookiejar
+import urllib.request
+import urllib.parse
+import lxml.etree
+import logging
+
+def get_webopac_xml(query="foo"):
+ cj = http.cookiejar.CookieJar()
+ opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
+ assert(isinstance(query, str))
+ f = opener.open("https://katalog.bibliotheken.winterthur.ch/webOPACClient.sisis/start.do?Query=-1=%22" + query + "%22")
+
+ postdata = {
+ 'methodToCall': 'submit',
+ 'listFormat': 'xml',
+ 'save': 'Speichern',
+ 'hitPart': 'pages',
+ 'hitFrom': 1,
+ 'hitTo': 200,
+ }
+
+ f = opener.open("https://katalog.bibliotheken.winterthur.ch/webOPACClient.sisis/hitOutput.do?" + urllib.parse.urlencode(postdata))
+ return(f)
+
+def decode_xml(f):
+ data = f.read()
+ root = lxml.etree.XML(data)
+ return(root)
+
+def parseopts():
+
+
+def init():
+
+
+def main():
+ f = get_webopac_xml("Green day")
+ root = decode_xml(f)
+
+ print(root)
+
+if __name__ == '__main__':
+ main()