Sto utilizzando Python Mechanize per aprire un sito Web, compilare un modulo e inviare tale modulo. In realtà è piuttosto semplice. Funziona finché non incontra i pulsanti di opzione e "seleziona" le caselle di input.TypeError: ListControl, deve impostare una sequenza (errore python)
br.open(url)
br.select_form(name="postmsg")
br.form['subject'] = "Is this good for the holidays? "
br.form['message'] = "I'm new to technology."
br.form['E'] = '0'
br.submit()
br.form['E'] = '0'
File "build/bdist.linux-x86_64/egg/ClientForm.py", line 2897, in __setitem__
File "build/bdist.linux-x86_64/egg/ClientForm.py", line 2092, in __setattr__
File "build/bdist.linux-x86_64/egg/ClientForm.py", line 2100, in _set_value
TypeError: ListControl, must set a sequence
Perché viene visualizzato questo errore? Perché non posso impostare E proprio come le caselle di testo? (E è un pulsante di scelta)
Modifica: questo è il modulo, secondo Web Developer.
Elements
Index Id Name Type Value Label Size Maximum Length State
0 subject subject text 35
2 message message textarea
3 identity identity select 1
13 action_btn hidden
14 _charset_ hidden
16 r hidden /Stocks_(A_to_Z)/Stocks_G
9 E radio 0
Checked
8 E radio 1
15 .crumb hidden 1n1Yo3MQae3
7 E radio 2
17 bn hidden 25263
6 E radio 3
5 E radio 4
4 E radio 5
12 SubmitCancel SubmitCancel submit Cancel
1 mbpostthreads threads button Check Existing Topics First
11 SubmitPost SubmitPost submit Post Message
10 SubmitPreview SubmitPreview submit Preview Message
18 yIdCoreIdUser hidden annamae41g
Fornire l'HTML per i pulsanti di opzione – Amirshk