urllib ??

Alan Kennedy alanmk at hotmail.com
Mon Nov 4 05:30:02 EST 2002


Rainer Malik wrote:

> hi !
> i have a rather simple problem using urllib to POST something to a
> server. my script looks like this:

>     .....
>     d['.cgifields']='Dbase3d'
>     query=urllib.urlencode(d)
>     url = 'http://tux.embl-heidelberg.de/ramensky/polyphen.cgi'
>     results = urllib.urlopen(url,query).read()
>     open ('/import/enterprise/home/rainer/test.html','w').write(results)
> 
> the problem i have is the following: when i call this script, i just
> get the main HP of the server with the values filled in the correct
> fields. but what i miss is the 'pressing of the submit button', so
> that i will get the result from the server. i have no idea how this
> should work.

Rainer,

To me, this does not make sense.

"Pressing of the Submit Button" only happens in browsers.

What you are doing above in your code is executing the same series of
actions as happens, behind the scenes, in a browser, when a user presses
a submit button.

You say you want to "get the result from the server". But the line of
code

results = urllib.urlopen(url,query).read()

Does exactly that. It opens a URL connection, transmits query data to
that URL, reads the results that come back, and names them with the name
"results".

Am I missing something here?

regards,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan



More information about the Python-list mailing list