468,471 Members | 1,702 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,471 developers. It's quick & easy.

CGI question


What's the best way of converting this:

'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'

....to something easily usable in a python CGI script?

Thanks!

Nov 25 '05 #1
8 1730
Dan Stromberg wrote:
What's the best way of converting this:

'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'

...to something easily usable in a python CGI script?


easily usable for what purpose?

if you want to extract the URL that seems to be hidden in that string,
something like:

url, junk = text.split("\x01", 1)
junk, url = url.split("\\?", 1)

should work.

</F>

Nov 26 '05 #2
On Sat, 26 Nov 2005 13:26:11 +0100, Fredrik Lundh wrote:
Dan Stromberg wrote:
What's the best way of converting this:

'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'

...to something easily usable in a python CGI script?


easily usable for what purpose?

if you want to extract the URL that seems to be hidden in that string,
something like:

url, junk = text.split("\x01", 1)
junk, url = url.split("\\?", 1)

should work.


Um, yeah. I can work out this sort of thing.

But I thought there might be a python module intended for parsing inputs
to CGI scripts? Sometimes using a pre-written module can contend with
issues you didn't know where going to come up...

Thanks!
Nov 27 '05 #3
Dan Stromberg <st******@dcs.nac.uci.edu> writes:
On Sat, 26 Nov 2005 13:26:11 +0100, Fredrik Lundh wrote:
Dan Stromberg wrote:
What's the best way of converting this:
'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'
...to something easily usable in a python CGI script?

easily usable for what purpose?
if you want to extract the URL that seems to be hidden in that string,
something like:
url, junk = text.split("\x01", 1)
junk, url = url.split("\\?", 1)
should work.

But I thought there might be a python module intended for parsing inputs
to CGI scripts? Sometimes using a pre-written module can contend with
issues you didn't know where going to come up...


Generally, input to CGI scripts are done via the Common Gateway
Interface (CGI). The cgi module does those things. Your example
doesn't look anything like a CGI string, though. Maybe if you told us
where it came from, we could recommend a module for dealing with such.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Nov 27 '05 #4
On Sat, 26 Nov 2005 13:26:11 +0100, Fredrik Lundh wrote:
Dan Stromberg wrote:
What's the best way of converting this:

'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'

...to something easily usable in a python CGI script?


easily usable for what purpose?

if you want to extract the URL that seems to be hidden in that string,
something like:

url, junk = text.split("\x01", 1)
junk, url = url.split("\\?", 1)

should work.

</F>


This is great, but is there no standard python module for taking
apart command line arguments to a CGI script? I'm not eager to reinvent
the wheel, at least not on this project :)
Nov 29 '05 #5
Dan Stromberg wrote:
What's the best way of converting this:

'hide\\?http://www.dedasys.com/articles/prog...\x012005-07-20
14:48'

...to something easily usable in a python CGI script?


easily usable for what purpose?

if you want to extract the URL that seems to be hidden in that string,
something like:

url, junk = text.split("\x01", 1)
junk, url = url.split("\\?", 1)

should work.

</F>


This is great, but is there no standard python module for taking
apart command line arguments to a CGI script? I'm not eager to reinvent
the wheel, at least not on this project :)


command-line arguments to CGI scripts?

I'm probably dense, but doesn't CGI scripts usually get their arguments via
environment variables and stdin ? and chr(1) and "hide\?" sure don't look
like standard URL separators to me...

if you want standard CGI argument handling, the "cgi" module contains all
the tools you need.

</F>

Nov 30 '05 #7
On Tue, 29 Nov 2005 12:53:26 -0800, Istvan Albert wrote:
See urlparse:

http://www.python.org/doc/current/li...-urlparse.html


This looks like precisely what I need for part of what I need to do.

I'm stoked that it knows how to take apart the "?" stuff.

I'm still wondering though, if there's some part of the python standard
modules that will convert those % escapes to ASCII or similar - and
perhaps any other conversions that I don't yet realize I need to handle...

Thanks!

Dec 2 '05 #8
> I'm still wondering though, if there's some part of the python standard
modules that will convert those % escapes to ASCII or similar - and


I believe that functionality is provided by the quote/unquote functions
in the urllib module:

http://www.python.org/doc/current/li...le-urllib.html

Istvan.

Dec 2 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mohammed Mazid | last post: by
3 posts views Thread by Stevey | last post: by
10 posts views Thread by glenn | last post: by
53 posts views Thread by Jeff | last post: by
56 posts views Thread by spibou | last post: by
2 posts views Thread by Allan Ebdrup | last post: by
3 posts views Thread by Zhang Weiwu | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.