8

mechanize でフォームを送信しようとしていますが、エラー (TypeError: ListControl, must set a sequence) が発生しました。すべてのフィールドを送信しようとしています。

mechanize 経由で取得したフォーム データ (for 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()

フォームオプションに正しい構文を使用していることを確認してください。ありがとう

4

1 に答える 1

14

typeフィールドは整数のリストを期待していますが、整数を 1 つだけ指定します。
これを変える:

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

これに:

br.form['type'] = ['22',]
于 2012-02-06T15:38:19.177 に答える