python request post doesn't submit
Question: I have a problem with request.post, instead of returning the html code with
the results I get back the html code of the starting side.

    
    
    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")
    

Could it be that I have to define which postmethod I want to use? Because
there are two in the html file. If this is the case how do I do that?(I want
to use the second one.)

    
    
    <FORM ACTION="result.cgi" METHOD=POST>
    <form action="capture_ul.cgi" method="post" enctype="multipart/form-data">
    

I am aware that there are similar questions here but the answers there didn't
help because the mistake was that params was used instead of files, which
shouldn't be a problem here.

Thanks in advance.


Answer: 1 - You are posting to the wrong url, it should be
`http://capture.caltech.edu/capture_ul.cgi`.

2 - There's an hidden field (`name='note'`) that must be sent (value of an
empty string will be enough).

    
    
    ...
    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)
    ...
    

