Python-Perl Translation
Ben Ocean
zope at thewebsons.com
Tue Jan 29 10:03:51 EST 2002
Excellent. Thank you!
BenO
At 09:19 AM 1/29/02 +0000, you wrote:
>Ben Ocean wrote:
>
>>#!/usr/bin/perl
>>($user_id,$banner_id,$page) = split(/&/,$ENV{QUERY_STRING});
>>$redirect =
>>"http://www.myaffiliateprogram.com/u/$user_id/t.asp?id=$banner_id&p=$page";
>>print "Location: $redirect\n\n";
>>exit;
>>I have this, but as you can see, I don't know what to substitute for
>>$ENV{QUERY_STRING}:
>>import string
>>import urllib
>>x = string.split("$ENV{QUERY_STRING}","&")
>>user_id = x[0]
>>banner_id = x[1]
>>page = x[2]
>>urlopen(http://www.myaffiliateprogram.com/u/$user_id/t.asp?id=$banner_id&p=$page)
>>
>>What do I do on the $ENV thing and how does the rest of the code look?
>>TIA,
>>BenO
>
>Why not just use the cgi module? No nee to parse the querystring yourself.
>
>from cgi import FieldStorage
>
>query = FieldStorage()
>user_id = query['user_id']
>banner_id = query['banner_id']
>page = query['page']
>
>etc. ...
>
>regards Max M
>
More information about the Python-list
mailing list