headers = {'HTTP_USER_AGENT':
    'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13'
    , 'HTTP_ACCEPT':
    'text/html,application/xhtml+xml,application/xml; q=0.9,*/*; q=0.8',
    'Content-Type': 'application/x-www-form-urlencoded'}
formFields = ('__VSTATE',
    '7TzretNIlrZiKb7EOB3AQE ... ...2qd6g5xD8CGXm5EftXtNPt+H8B'), ('__VIEWSTATE'
    , ''), ('__EVENTVALIDATION',
    '/wEWDwL+raDpAgKnpt8nAs3q+pQOAs3q/pQOAs3qgpUOAs3qhpUOAoPE36ANAve684YCAoOs79EIAoOs89EIAoOs99EIAoOs39EIAoOs49EIAoOs09EIAoSs99EI6IQ74SEV9n4XbtWm1rEbB6Ic3/M='
    ), ('ctl00_RadScriptManager1_HiddenField', ''), ('ctl00_tabTop_ClientState'
    , ''), ('ctl00_ContentPlaceHolder1_menuMain_ClientState', ''), (
    'ctl00_ContentPlaceHolder1_gridMain_ClientState', ''), (
    'ctl00$ContentPlaceHolder1$chkOptions$0', 'on'), (
    'ctl00$ContentPlaceHolder1$chkOptions$1', 'on'), (
    'ctl00$ContentPlaceHolder1$chkOptions$2', 'on'), (
    'ctl00$ContentPlaceHolder1$txtSearch', 'york'), (
    'ctl00$ContentPlaceHolder1$lstYears', 'All Years'), (
    'ctl00$ContentPlaceHolder1$lstTypeBasic', 'All Types'), (
    'ctl00$ContentPlaceHolder1$btnSearch', 'Search Legislation')
encodedFields = urllib.parse.urlencode(formFields)
req = urllib.request.Request(uri, encodedFields, headers)
f = urllib.request.urlopen(req)
try:
    fout = open('tmp.htm', 'w')
except:
    print('Could not open output file\n')
fout.writelines(f.readlines())
fout.close()
how to submit query to .aspx page in python