我正在学习Python,并试图自动从网页下载文件。我尚未进行测试,因为我需要知道自己是否步入正轨。我希望脚本执行按网页上按钮的操作,即创建文件并开始下载该文件。
下面是带有按钮的页面信息:
//输入type =“提交” name =“导出” value =“导出” //
// form name =“ export” action =“ / cgi-bin / configuration.cgi” method =“ post” enctype =“ multipart / form-data” id =“ export” //
import urllib3
import requests
req = requests.post('<IP Addy>/cgi-bin/configuration.cgi', 'Export')
with open('file.data', 'wb') as file:
file.write(req.content)