excelHome上传附件

fileFullPath=r'E:\uploadTest.rar'  #此处输入要上传的文件的路径
fileName=fileFullPath.split('\\')[-1]  #格式后缀要留下
import requests

s=requests.session()
url='http://club.excelhome.net/misc.php?mod=swfupload&action=swfupload&operation=upload&fid=2'
#files参数模拟多个表单:{f1:(name,Object,Content-Type,per-partheaders),f2:()…}
f={'uid':(None,'24810**'), #本例只需模拟这3个form-data,其他的都非必需;**为学号-1
   'hash':(None,'8dfae1d86bfc714ec489e6518094d2b2'),
   'Filedata':(fileName,open(fileFullPath,'rb'),'application/octet-stream')
 }
result=s.post(url,files=f)
print(result.text)

#出现一串数字则为成功,
http://club.excelhome.net/forum.php?mod=post&action=newthread&fid=2,到论坛 这个 发帖的界面可看到“未使用的附件”的提示。

excelHome上传附件_第1张图片

你可能感兴趣的:(爬虫)