Why does mechanization list one form?

If you run the following program:

import mechanize

br = mechanize.Browser()
br.open("http://hansardindex.ontla.on.ca/hansarde.asp")
for f  in br.forms():
    print f.name

Only one line of output is output. However, if you go to a page, there are many forms with names like "DateFrom". Why doesn't mechanization list other forms?

+3
source share
1 answer

There is a distinction between Forms and Input. A form can contain many input fields.
see http://www.w3schools.com/html/html_forms.asp

The mechanism is right, there is only one form, but with several input fields.

, , , . , , "searchcontents" :

form = forms[0]
form["searchcontents"] = "keyword"

, , http://wwwsearch.sourceforge.net/mechanize/forms.html

+3

Source: https://habr.com/ru/post/1773944/


All Articles