diff options
author | Florian Bruhin <me@the-compiler.org> | 2012-02-12 14:06:55 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2012-02-12 14:06:55 +0100 |
commit | 0280d25dd397dd9bc64a2bb92d8d71a8d24d0823 (patch) | |
tree | 88e6ff434d7fbfcc3145ffb23b2876b5a28c8e93 | |
parent | 5105fd1b68ffe250415c9b2a9f584927d0a808a0 (diff) | |
download | webopac-0280d25dd397dd9bc64a2bb92d8d71a8d24d0823.tar.gz webopac-0280d25dd397dd9bc64a2bb92d8d71a8d24d0823.zip |
Query escaping, pretty printing
-rw-r--r-- | webopac.py | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -12,6 +12,7 @@ def get_webopac_data(query, baseurl): cj = http.cookiejar.CookieJar() opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) assert(isinstance(query, str)) + query = urllib.parse.quote_plus(query) f = opener.open(baseurl + "start.do?Query=-1=%22" + query + "%22") postdata = { @@ -71,8 +72,15 @@ def main(): f = get_webopac_data(args[0], baseurl=options.baseurl) data = decode_csv(f) for row in data: - print(row) - print() + if " # CD_" in row['Signatur']: + formatdict={ + 'title': row['Titel'], + 'author': row['Autor'], + 'year': row['Erscheinungsjahr'], + } + print("Title: {title}\nAuthor: {author}\n" + "Year: {year}".format(**formatdict)) + print() if __name__ == '__main__': main() |