How do you select choices in a form using Python?

后端 未结 2 1885
梦谈多话
梦谈多话 2021-02-02 02:20

I\'d like to know how to select options in a form that is formatted like

  
                  
                        
    
提交评论

  • 2021-02-02 03:00

    When you say the page has multiple forms, do you mean there are multiple <form> elements on the page, or multiple form fields (like <select>)?

    The Mechanize docs for python sketch out how to select list items. Here's the sample they provide:

    # Controls that represent lists (checkbox, select and radio lists) are
    # ListControl instances.  Their values are sequences of list item names.
    # They come in two flavours: single- and multiple-selection:
    form["favorite_cheese"] = ["brie"]  # single
    

    In your case, the code to select Value1 would look like this:

    form["FORM1"] = ["Value1"]
    
    0 讨论(0)
  • 提交回复
    热议问题