CGI question
LordLaraby
Lord.Laraby at gmail.com
Sat Jan 7 01:44:15 EST 2006
sophie,
If you have the URL in a variable, it's easy to parse it into it's
components (one of which is the query string) like so:
>>> from urllib2.urlparse import urlparse
>>> urlparse( \
"http://user@www.xyz.org:8080/mytext.php;hellothere?this=test+value&and=that+one#anchor")
('http', 'user at www.xyz.org:8080', '/mytext.php', 'hellothere',
'this=test+value&and=that+one', 'anchor')
>>> print _[4]
this=test+value&and=that+one
>>> print _.split('&')
['this=test+value','and=that+one']
Then just use unquote_plus() from urllib to get the original query
arguments.
Hope that fills in some of the missing links. :-)
LL
More information about the Python-list
mailing list