I have been working on this for couple days now. Can not really find how to make this work. I am fairly new to aspx websites and fetching information out of them.
I am trying to login/authenticate on a website that uses aspx pages. So I followed this thread which really helped me get this in motion. (Last Answer)
Following those directions, I write:
url = "http://samplewebsite/Main/Index.aspx" # Logon page
username = "user"
password = "password"
browser = RoboBrowser(history=True)
# This retrieves __VIEWSTATE and friends
browser.open(url)
signin = browser.get_form(id='form1')
print(signin)
This is the outcome of that print statement:
<RoboForm __VIEWSTATE=/wEPDwULLTE5ODM2NTU1MzJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQlidG5TdWJtaXRriD1xvrfrHuJ/0xbQM08yEjyoUg==, __VIEWSTATEGENERATOR=E78488FE, adminid=, btnSubmit=, pswd=>
So it is obvious that I am retrieving the information correctly. Now I have 3 input fields:
adminid
btnSubmit
pswd
Which I can use in the following manner:
signin["adminid"].value = username
signin["pswd"].value = password
signin["btnSubmit"].value = "btnSubmit.x=29&btnSubmit.y=22"
My only problem is the last field btnSubmit
which I do not know how to input a value since this is of the following type:
<input type="image" name="btnSubmit" id="btnSubmit" tabindex="3" src="../image/login_btn.gif" style="height:41px;width:57px;border-width:0px;" />
when I submit on the website, using the Chrome Tools I get the following outcome:
__VIEWSTATE:/wEPDwULLTE5ODM2NTU1MzJkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQlidG5TdWJtaXRriD1xvrfrHuJ/0xbQM08yEjyoUg==
__VIEWSTATEGENERATOR:E78488FE
adminid:user
btnSubmit.x:23
btnSubmit.y:15
pswd:password
Where basically the x,y
positions are where I clicked on the page. Really do not know how to do this request through Python. Used this to no avail.