0

I am creating an application for my university in which students has to login as to get his data.The site posts the params like thisenter image description here


content from that page that post the params.

<input checked="checked" id="SchSel_chkSkip" name="SchSel$chkSkip" type="checkbox"/>
 <input id="SchSel_hidLastLogin" name="SchSel$hidLastLogin" type="hidden"/>
 <input id="SchSel_hidSchoolId" name="SchSel$hidSchoolId" type="hidden" value="-1"/>
 <input id="SchSel_hidSchoolName" name="SchSel$hidSchoolName" type="hidden"/>
 <input id="SchSel_hidCoreUserDet" name="SchSel$hidCoreUserDet" type="hidden"/>
 <input id="SchSel_hidSessionId" name="SchSel$hidSessionId" type="hidden" value="-1"/>
 <input id="SchSel_hidActiveSchool" name="SchSel$hidActiveSchool" type="hidden" value="-1"/>
 <input id="SchSel_hidReportingDet" name="SchSel$hidReportingDet" type="hidden" value="-1"/>
 <input id="SchSel_hidActiveSession" name="SchSel$hidActiveSession" type="hidden" value="-1"/>
 <input id="SchSel_hidHitCount" name="SchSel$hidHitCount" type="hidden" value="378284"/>
 <input id="SchSel_hidSchoolAddress" name="SchSel$hidSchoolAddress" type="hidden" value="0"/>
 <input id="SchSel_hdnLoginAsUser" name="SchSel$hdnLoginAsUser" type="hidden"/>

The only data I know is SchSel$txtUserName and SchSel$txtPassword which i can post but how to get other values


What I tried :

import requests

s = requests.Session()
url = 'https://nucleus.niituniversity.in/Default.aspx'
login_data = {'ScriptManager1' : 'SchSel$up|SchSel$btnLogin',
          '__LASTFOCUS' : '',
          '__EVENTTARGET' : '',
          '__EVENTARGUMENT' : '',
          '__VIEWSTATE' :   '/wEPDwUKMTg3OTYzNDk4Nw9kFgICAw9kFhICAQ8PFgIeB1Zpc2libGVoZGQCAg8PFgIfAGhkZAIDDwdkxvZ2luDw9kZmQaZNVi16vCv',
          '__VIEWSTATEGENERATOR' : 'CA0B0334',
          'SchSel$cmbUserType' : 'Student',
          'SchSel$txtUserName' : 'user',
          'SchSel$txtPassword' : '1234',
          'SchSel$chkSkip' : 'on',
          'SchSel$hidLastLogin' : '2016-2017',
          'SchSel$hidSchoolId' : '1',
          'SchSel$hidSchoolName' : 'School name',
          'SchSel$hidCoreUserDet' : '815106',
          'SchSel$hidSessionId' : '8',
          'SchSel$hidActiveSchool' : '1',
          'SchSel$hidReportingDet' : '0',
          'SchSel$hidActiveSession' : '1',
          'SchSel$hidHitCount' : '3',
          'SchSel$hidSchoolAddress' : 'Address',
          'SchSel$hdnLoginAsUser' : '',
          '__ASYNCPOST' : 'true',
          'SchSel$btnLogin.x' : '42',
          'SchSel$btnLogin.y' : '14'
            }
s.post(url,data = login_data)

res = s.get('Protected page')

But failed to login.why it is failing though i am posting the required data.?

12
  • Because you cannot use the the values from your browser, you need to parse them from your session stackoverflow.com/questions/37577405/… Commented Aug 1, 2016 at 13:46
  • What headers are you passing? Commented Aug 1, 2016 at 13:53
  • User-Agent :Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0,cookie:ASP.NET_SessionId=ow0xuxtckpa5aksglq0o5ngl Commented Aug 1, 2016 at 13:55
  • I don't know what's wrong.I've tried all. Commented Aug 1, 2016 at 14:02
  • 1
    try pastebin.com/hdBSVyqg Commented Aug 2, 2016 at 22:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.