mechanize select form using id

后端 未结 7 1697
天命终不由人
天命终不由人 2020-12-18 18:31

I am working on mechanize with python.

The

7条回答
  •  时光说笑
    2020-12-18 18:34

    You can use the predicate param of the function select_form of the Browser class. Like this:

    from mechanize import Browser, FormNotFoundError
    
    try:
       br.select_form(predicate=lambda frm: 'id' in frm.attrs and frm.attrs['id'] == 'sblock')
    except FormNotFoundError:
      print("ERROR: Form not Found")   
    

提交回复
热议问题