summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2012-02-12 12:01:43 +0100
committerFlorian Bruhin <me@the-compiler.org>2012-02-12 12:01:43 +0100
commit206eb879f8cc8cd281e520e43856647354192cfe (patch)
tree4806b819ba6aab577f286f58fad3ae8132bb3f19
parent2c3f2d8270f520cda9e733ff642cdd71dd6f3ee3 (diff)
downloadwebopac-206eb879f8cc8cd281e520e43856647354192cfe.tar.gz
webopac-206eb879f8cc8cd281e520e43856647354192cfe.zip
Add parseopts()
-rw-r--r--webopac.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/webopac.py b/webopac.py
index f608793..7cd8821 100644
--- a/webopac.py
+++ b/webopac.py
@@ -7,10 +7,12 @@ import lxml.etree
import logging
def get_webopac_xml(query="foo"):
+ baseurl="https://katalog.bibliotheken.winterthur.ch/webOPACClient.sisis/"
+
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")
+ f = opener.open(baseurl + "start.do?Query=-1=%22" + query + "%22")
postdata = {
'methodToCall': 'submit',
@@ -21,7 +23,7 @@ def get_webopac_xml(query="foo"):
'hitTo': 200,
}
- f = opener.open("https://katalog.bibliotheken.winterthur.ch/webOPACClient.sisis/hitOutput.do?" + urllib.parse.urlencode(postdata))
+ f = opener.open(baseurl + "hitOutput.do?" + urllib.parse.urlencode(postdata))
return(f)
def decode_xml(f):
@@ -30,7 +32,12 @@ def decode_xml(f):
return(root)
def parseopts():
-
+ parser = optparse.OptionParser("usage: %prog [options]")
+ parser.add_option('-l', '--log', dest='loglevel', help='Set loglevel',
+ default=0)
+ (options, args) = parser.parse_args()
+ return (options, args)
+
def init():