views:

25

answers:

1

I am using twill and python to write a web crawler. showforms() returns

Form name=customRatesForm (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
10    originState              hidden    originState  TN 
11    destState                hidden    destState    IL 
12    originZip                text      originZip    37130 
13    destZip                  text      destZip      60602 
16    classes                  select    classes1     ['0000'] of ['0000', '0500', '0550', ... 
17    weight                   text      weight1      600 
18    weight                   text      weight2       
19    weight                   text      weight3       
20    weight                   text      weight4       
30 1  submit                   submi ... submit      

I've taken out most of the rows to make it easier to read. My problem is that there are actually 12 selects and all of them have the name 'classes'. These pass through CGI as a list. However, Twill seems unable to distinguish between them. Also, when I run

fv('1', 'classes', '0500')

I get the following error:

_mechanize_dist.ClientForm.AmbiguityError: id=None name='0500' label=None

I have tried a few workarounds including renaming the selects with their ids and then rewriting the submit function to use a jQuery selector and reassign their 'name' attribute back to 'classes':

$('.myclasses').attr('name', 'classes');

when I view this in the browser, it seems to reassign them as expected. However, twill's headers still show it as submitting with the names 'classes1', 'classes2', etc.

any help would be much appreciated. I'm out of workarounds that I know of. Because this isn't my page, I am bound by their controller's expectations of a list for the 'classes' selects.

A: 

as far as i've found till now, there is no way to do this with twill. any solution is going to be a workaround outside of twill.

thejew