How to Webscrape data from a classic asp website using python. I am having trouble getting the result after submitting the POST form
<p>I am beginner in Web scraping and I have become very much interested in the process.
I set for myself a Project that can keep me motivated till I completed the project.</p>

<h1>My Project</h1>

<p>My Aim is to write a Python Program that goes to my university results page(which happens to be a " xx.asp") and enters my</p>

<ol>
<li>MY EXAM NO </li>
<li>MY COURSE </li>
<li>SEMESTER and submit it to the website.</li>
</ol>

<p>Clicking on the submit button leads to another "yy.asp" page in which my results are displayed. But I am having a lot of trouble doing the same.</p>

<h2>Some Sample Data to try it out</h2>

<p><strong>The Results Website:</strong> <a href="http://result.pondiuni.edu.in/candidate.asp" rel="nofollow">http://result.pondiuni.edu.in/candidate.asp</a></p>

<p><strong>Register Number:</strong> 15te1218</p>

<p><strong>Degree:</strong> BTHEE</p>

<p><strong>Exam:</strong> Second</p>

<p>Could anyone give me directions of how I am to accomplish the task?</p>

<p>I have written a sample program that I am not really proud of or nor does it work as I wanted. The following is the code that I wrote. I am a beginner so sorry if I did something terribly wrong. Please correct me and would be awesome if you could guide me to solve the problem.</p>

<p>The website is a .asp website not .aspx.
I have provided sample data so that you can see whats happening where we submit a request to the website.</p>

<h2>The Code</h2>

<pre><code>import requests

with requests.Session() as c:
    url='http://result.pondiuni.edu.in/candidate.asp'
    url2='http://result.pondiuni.edu.in/ResultDisp.asp'
    TXTREGNO='15te1218'
    CMBDEGREE='BTHEE~\BTHEE\result.mdb'
    CMBEXAMNO='B'
    DPATH='\BTHEE\result.mdb'
    DNAME='BTHEE'
    TXTEXAMNO='B'
    c.get(url)

payload = {

    'txtregno':TXTREGNO,
    'cmbdegree':CMBDEGREE,
    'cmbexamno':CMBEXAMNO,
    'dpath':DPATH,
    'dname':DNAME,
    'txtexamno':TXTEXAMNO
}
post_request = requests.post(url, data=payload)
page=c.get(url2)
</code></pre>

<p>I have no idea what to do next so that I can retrieve my result page(displayed in <code>url2</code> from the code). All the data is entered in link <code>url</code> in the program(the starting link were all the info is entered) from where after submitting takes is to <code>url2</code> the results page.
Please help me make this program.</p>

<p>I took all the post form parameters from Chrome's Network Tab.</p>

<p>You are way over complicating it and you have <em>carriage returns</em> in your post data so that could never work:</p>

<pre><code>In [1]: s = "BTHEE~\BTHEE\result.mdb"

In [2]: print(s) # where did "\result.mdb" go?
esult.mdbHEE

In [3]: s = r"BTHEE~\BTHEE\result.mdb" # raw string

In [4]: print(s)
BTHEE~\BTHEE\result.mdb
</code></pre>

<p>So fix you form data and just post to get to your results:</p>

<pre><code>import requests

data = {"txtregno": "15te1218",
        "cmbdegree": r"BTHEE~\BTHEE\result.mdb", # use raw strings
        "cmbexamno": "B",
        "dpath": r"\BTHEE\result.mdb",
        "dname": "BTHEE",
        "txtexamno": "B"}

results_page = requests.post("http://result.pondiuni.edu.in/ResultDisp.asp", data=data).content
</code></pre>

python html forms web web-scraping