How to trigger a smart link?

Chris Rebert clp2 at rebertia.com
Wed Feb 4 20:27:38 EST 2009


On Wed, Feb 4, 2009 at 5:16 PM, Muddy Coder <cosmo_general at yahoo.com> wrote:
> Hi All,
>
> Using urllib2 can trigger CGI script in server side. However, I
> encountered a problem of the so-called smart link. When a fairly large
> site, the server needs to track the identifier of each request from
> client, so it generated an ugly escape string attached on url. It
> seems that I must get this ugly escape string first then I can can
> fill the string into my url, and the CGI script on server side can be
> triggered. For example,
>
> http://whatever.com/submitreal.cgi?fp=3xD0TuGMp7C7gP1TRD
>
> displays a submit form. If I just copy
>
> http://whatever.com/submitreal.cgi
>
> to url address, without the escape string ?fp=3xD0TuGMp7C7gP1TRD, the
> browser will report error of 404
>
> I found Python has a module of escape, but I don't know how to use
> this module to solve the problem above. Or, I just wonder does urllib2
> has such a method to handle smart link? Thanks!

I think you'll need to fetch whatever webpage contains the link with
the magic URL, and then use an HTML parser (e.g. BeautifulSoup or
lxml) to parse the URL out of the page. Then just fetch the URL you
obtained.
I doubt you can just generate the escape string yourself, you need the
cooperation of the CGI script on the other end; hence the need to
fetch the known page.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list