2

I've been using this question as a guide on how to change a form's controls if the control name is None. I've done this:

basket = br.open('http://www.numbeo.com/cost-of-living/city_result.jsp')
read_it = basket.read()
br.form = list(br.forms())[0]
br.set_value("put_city_here", nr=1)

for control in br.form.controls:
    print control
    print ' ', "type=%s, name=%s" % (control.type, control.name)

br.form["put_city_here"] = 'New York'
br.submit()

This is what the controls look like before I try to change it:

<HiddenControl(where=http://www.numbeo.com/cost-of-living/city_result.jsp) (readonly)>
  type=hidden, name=where
<TextControl(<None>=)> #Control that I'm interested in
  type=text, name=None
<HiddenControl(city_id=) (readonly)>
  type=hidden, name=city_id
<HiddenControl(name_city_id=) (readonly)>
  type=hidden, name=name_city_id

And after:

<HiddenControl(where=http://www.numbeo.com/cost-of-living/city_result.jsp) (readonly)>
  type=hidden, name=where
<TextControl(<None>=put_city_here)> #Control that I'm interested in 
  type=text, name=None
<HiddenControl(city_id=) (readonly)>
  type=hidden, name=city_id
<HiddenControl(name_city_id=) (readonly)>
  type=hidden, name=name_city_id

I don't know what I need to do in order for the control name, rather than what the control represents, to change. Thanks for you help.

Community
  • 1
  • 1
otteheng
  • 594
  • 1
  • 9
  • 27

0 Answers0