Python3.7机械化上传Zip文件作为在线表单的一部分

时间:2019-06-14 18:09:00

标签: python python-3.x forms mechanize

尝试将zip文件作为其他选择上载为表单的一部分。尝试对br.form.add_file()进行各种输入后,python仍然会吐出错误。另外不确定我是否需要提供表单上载部分的名称/ ID。

尝试使用ZipFile加载zip并将其直接传递给上传功能,还尝试提供MIME类型和上传文件名。

br.select_form(id='upload_form')
print('Supplying Text...')
br['chapter_name'] = 'test'
br['chapter_number'] = '55'
zip = zips / '16x16.zip'
#with ZipFile(zip, 'r') as zip:
br.form.add_file(open(zip))
print('Submitting form...')
response = br.submit()```

Current setup provides this error: 'charmap' codec can't decode byte 0x9d in position 199: character maps to <undefined>

0 个答案:

没有答案