我正在尝试提交一个表单与机械,但遇到了一个错误(TypeError: ListControl,必须设置一个序列)后,谷歌了一段时间,并尝试了几个不同的解决方案,我没有能够解决这个问题。我正在试着提交所有的字段。
通过mechanize获取的表单数据(对于br.forms()中的f,print: f)
<POST http://www.example.com/takeupload.php multipart/form-data
<HiddenControl(MAX_FILE_SIZE=1000000) (readonly)>
<TextControl(<None>=http://www.example.com:81/test.php?pass=550) (readonly)>
<FileControl(file=<No files added>)>
<TextControl(name=)>
<SelectControl(type=[*0, 23, 22, 1, 10, 7, 18, 4, 21, 56, 20, 60, 5, 19, 6, 55, 63, 9])>
<CheckboxControl(strip=[strip])>
<FileControl(nfo=<No files added>)>
<TextareaControl(descr=)>
<SubmitControl(<None>=Do it!) (readonly)>>我当前的代码
br.open('http://www.bitfarm.co.za/upload.php')
br.select_form(nr=4)
filename = 'test.torrent'
br.form.add_file(open(filename), 'application/x-bittorrent', filename, name='file')
br.form['name'] = 'test'
br.form['type'] = '22'
br.form['strip'] = '0'
br.form['nfo'] = ''
br.form['descr'] = 'This is the desc'
br.submit()请您协助并检查我是否使用了正确的表单选项语法。谢谢
发布于 2012-02-06 23:38:19
type字段需要您提供一个整数列表,但您只提供了一个整数。
更改此设置:
br.form['type'] = '22'要这样做:
br.form['type'] = ['22',]https://stackoverflow.com/questions/9161764
复制相似问题