如何使用机械化python上传文件?

问题描述

我需要以这种形式上传文件(txt):

press to upload file

添加按钮的结构如下:

code of add button

上传后,我必须使用发送按钮发送文件

enter image description here

发送按钮的结构如下:

enter image description here

搜索并仅找到这样的示例:

browser.select_form(name = 'formForm')
browser.form.add_file(open(directory))
response = browser.submit()

但是我没有成功,如果有人能帮助我,谢谢你

解决方法

这就是您要寻找的:

br.form.add_file(open(filename),'text/plain',filename)