Unsuccessful post to asp.net form using Python requests
Question: I am attempting to use Python requests to post a value to the "employer" form
in the <http://www.myvisajobs.com/Search_Visa_Sponsor.aspx?N=>

This is what I have tried so far in Python:

    
    
    import requests
    url = "http://www.myvisajobs.com/Search_Visa_Sponsor.aspx?N="
    data = {"ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$txtCompany":"Microsoft"}
    r = requests.post(url,data)
    print(r.text)
    

Which returns only the original HTML. I am trying to return the resulting
HTML. My gut feeling is I am doing something fundamentally wrong, but I am not
sure what.


Answer: There are much more parameters sent in the search POST request than just the
`ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$txtCompany` referring to
the company name.

Instead, to make things transparent and easy, I would use
[`RoboBrowser`](https://github.com/jmcarp/robobrowser) that would "auto-fill"
other form POST parameters needed. Example working code:

    
    
    from robobrowser import RoboBrowser
    
    
    url = "http://www.myvisajobs.com/Search_Visa_Sponsor.aspx?N="
    
    browser = RoboBrowser(history=True)
    browser.open(url)
    
    form = browser.get_form(id='aspnetForm')
    form['ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$txtCompany'].value = 'Microsoft'
    browser.submit_form(form)
    
    results = browser.select('div#ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_divContent table tr')[1:]
    for result in results:
        cells = result.find_all("td")
    
        print(cells[2].get_text(strip=True))
    

It prints the company names from the search results:

    
    
    Microsoft Corporation
    Microsoft Operations Puerto Rico, Llc
    Microsoft Caribbean, Inc.
    Standard Microsystems Corporation
    4Microsoft Corporation
    Microsoft Business Solutions Corporation
    Microsoft C98052orporation
    Microsoft Ccrporation
    Microsoft Coiporation
    Microsoft Copporation
    Microsoft Corforation
    Microsoft Licensing, GP
    Microsoft Way
    Microsoftech Inc
    Quantitative Micro Software Llc
    Webtv Networks Microsoft Sub
    Microsoft
    FAST, A Microsoft Subsidiary
    Microsoft Corporation - Sham
    Microsoft Partner Careers (sponsored By Microsoft Dynamics)
    Microsoft Iberica
    Microsoft Karthi
    

