urllib redirect
Anthony J Wilkinson
anthony at dstc.edu.au
Tue Apr 18 02:18:06 EDT 2000
On Tue, 18 Apr 2000, Thomas wrote:
> I've got a pretty tame question.
>
> I want one of my functions to redirect the URL.
> (ie I call the script and off I go to www.spam.com)
>
> So, here's what I get, and have not overcome yet:
>
> import urllib
> def simpleredirect() :
> ############
> print "Content-type: text/html"
> print urllib.urlopen('http://www.spam.com').read()
>
> simpleredirect()
You really aren't redirecting but attempting to get the data yourself. If
you just print out the following you can use the browser's own redirection
facility.
Content-type: text/html
<html>
<head>
<meta HTTP-EQUIV="REFRESH" CONTENT="0; URL=http://www.spam.com/">
<title> redirect page</title>
</head>
<body>
If your browser does not support redirection, click
<a HREF="http://www.spam.com/">here</a> to continue.
</body>
</html>
Cheers,
Anthony
_____________________________________________________________________
Anthony J Wilkinson anthony at dstc.com
Software Engineer http://dstc.com
DSTC Pty Ltd Ph: +61 7 3365 4310
More information about the Python-list
mailing list