for link in br.links():įollow link and click links is the same as submit and click request = br.click_link(link) Sometimes it is easier to get them all and find the link you want from the text. When your form is complete you can submitįollowing links in mechanize is a hassle because you need the have the link object. OR disable all of them like so for control in br.ntrols: Text controls can be set as a string if control.type = "text": # means it's class ClientForm.TextControlīr = "stuff here" # equivalentĬontrols can be set to readonly and disabled. Print control # selected value is starredīr = # equivalent and more normal Print " name=%s values=%s" % (item.name, str())īecause ‘Select’ type controls can have multiple selections, they must be set with a list, even if it is one element. Having a select control tells you what values can be selected if control.type = "select": # means it's class ClientForm.SelectControl Print "type=%s, name=%s value=%s" % (control.type, control.name, br)Ĭontrols can be found by name control = br.form.find_control("controlname") Iterate through the controls in the form. To go on the mechanize browser object must have a form selected br.select_form("form1") # works when form has a nameīr.form = list(br.forms()) # use when form is unnamed List the forms that are in the page for form in br.forms(): Response1 = br.response() # get the response again Print response.read() # the text of the page
0 Comments
Leave a Reply. |