question: script to input data into a webpage and then retrieve the result?

jiang.haiyun at gmail.com jiang.haiyun at gmail.com
Sun Oct 22 07:21:22 EDT 2006


Christoph Haas 写道:

> On Sunday 22 October 2006 08:06, mxywp wrote:
> > Could someone help me with this or share an example script with me?
> >
> > Here is what I want to accomplish:
> > (1) input 3 values into 3 boxes on a web page
> > (2) there is an authentication code each time you access this page and I
> > have to write this code into the fourth box on the same page (3) click
> > "submit" button
> > (4) this web page will turn into a page with a table having a value
> > calculated from my inputs (5) extract this value into a local file
> > (6) repeat the above for 12000 times.
> >
> > I would really appreciate it if someone can tell me how to do it using
> > python script. I am new to python web programming.
>
> Dark side way:
>  http://www.idyll.org/~t/www-tools/twill.html
>

The main task is to constitute a correct URL.
e.g. the requested page is www.somepage.com,
first input form'id is input1, and respectively.

The request URL should be
'www.somepage.com?input1=value1&input2=value2',
post it and you'll get the response page .

Just do:

import urllib

value1=getValue1()
.
.
.

url='www.somepage.com?input1='+str(value1)+'&input2='+str(value2)
resp=urlopen(url)
parseResp(resp)

Problem: if the authentication code is an image, how to deal with it?

:)Sorry for my poor english.




More information about the Python-list mailing list