使用机械化提交表单(TypeError:ListControl,必须设置顺序) [英] Submitting a form with mechanize (TypeError: ListControl, must set a sequence)

查看:88
本文介绍了使用机械化提交表单(TypeError:ListControl,必须设置顺序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用机械化提交表单,但遇到错误(TypeError:ListControl,必须设置一个序列)在谷歌搜索了一段时间并尝试了几种不同的解决方案后,我无法解决问题.我正在尝试提交所有字段.

I'm trying to submit a form with mechanize but have run into an error (TypeError: ListControl, must set a sequence) After googling for some time and trying a couple of different solutions I haven't been able to solve the issue. I'm trying to submit all the fields.

通过机械化获取的表单数据(对于br.forms()打印中的f:f)

The form data fetched via mechanize (for f in br.forms() 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()

请协助您,检查我是否为表单选项使用了正确的语法.谢谢

Please could you assist and check I'm using the right syntax for the form options. Thanks

推荐答案

type字段要求您提供整数列表,但您只提供一个整数.
更改此:

type field expects a list of integers from you, but you provide just one integer.
Change this:

br.form['type'] = '22'

对此:

br.form['type'] = ['22',]

这篇关于使用机械化提交表单(TypeError:ListControl,必须设置顺序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆