Python Mechanize select form FormNotFoundError

后端 未结 2 728
星月不相逢
星月不相逢 2021-02-14 10:14

I want to select a form with mechanize. This is my code:

br = mechanize.Browser()
self.br.open(url)
br.select_form(name=\"login_form\")

The for

2条回答
  •  长发绾君心
    2021-02-14 10:30

    a little more readable:

    class Element_by_id:
        def __init__(self, id_text):
            self.id_text = id_text
        def __call__(self, f, *args, **kwargs):
            return 'id' in f.attrs and f.attrs['id'] ==self.id_text
    

    then:

    b.select_form(predicate=Element_by_id("login_form"))
    

提交回复
热议问题