python请求post不';不要屈服

python请求post不';不要屈服,python,Python,我对request.post有一个问题,我没有返回带有结果的html代码,而是返回起始端的html代码 import requests def test(pdb): URL = "http://capture.caltech.edu/" r = requests.post(URL,files={"upfile": open( pdb)}) content=r.text print(content) print(r.headers) def main():

我对request.post有一个问题,我没有返回带有结果的html代码,而是返回起始端的html代码

import requests
def test(pdb):
   URL = "http://capture.caltech.edu/"
   r = requests.post(URL,files={"upfile": open( pdb)})
   content=r.text
   print(content)
   print(r.headers)



def main():
  test("Model.pdb")
是否我必须定义我想要使用的postmethod?因为html文件中有两个。如果是这种情况,我该怎么做?(我想使用第二个。)


我知道这里也有类似的问题,但答案没有帮助,因为错误是使用了params而不是文件,这在这里应该不是问题


提前感谢。

1-您发布到了错误的url,应该是
http://capture.caltech.edu/capture_ul.cgi

2-必须发送一个隐藏字段(
name='note'
)(空字符串的值就足够了)


如果您要发布到主页,这些表单建议您应该发布到
http://capture.caltech.edu/result.cgi
http://capture.caltech.edu/capture_ul.cgi
<FORM ACTION="result.cgi" METHOD=POST>
<form action="capture_ul.cgi" method="post" enctype="multipart/form-data">
...
def test(pdb):
   URL = "http://capture.caltech.edu/capture_ul.cgi"
   r = requests.post(URL,files={"upfile": open(pdb)}, data={'note': ''})
   content=r.text
   print(content)
   print(r.headers)
...