All pastes #557166 Raw Edit

ezproxify

public python v1 · immutable
·published 2007-06-10 21:46 UTC
rendered paste body
#!/usr/bin/env python"""Given a url on the command line, transforms it to go through UCT'sezproxy. Useful for accessing online journals. Probably buggy."""import reimport sysurlpattern = re.compile("""(?P<proto>[a-z]+://)?                           (?P<host>[^:/]+)                           (?::(?P<port>\d+))?                           (?P<path>.*)""", re.VERBOSE)match = urlpattern.match(sys.argv[1])print """http://%(port)s-%(host)s.ezproxy.uct.ac.za:2048%(path)s""" % \         {'port': match.group('port') or 80,          'host': match.group('host'), 'path': match.group('path')}