Guest User

Untitled

a guest
Aug 2nd, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. headers = {
  2.     "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36",
  3.     "X-MicrosoftAjax": "Delta=true",
  4.     "X-Requested-With": "XMLHttpRequest"}
  5.  
  6. with requests.Session() as s:
  7.     url = 'https://nucleus.niituniversity.in/Default.aspx'
  8.     soup = BeautifulSoup(s.get(url).content)
  9.  
  10.     login_data = {'ScriptManager1': 'SchSel$up|SchSel$btnLogin',
  11.                   '__LASTFOCUS': '',
  12.                   '__EVENTTARGET': '',
  13.                   '__EVENTARGUMENT': '',
  14.                   '__VIEWSTATE': soup.select_one("#__VIEWSTATE")["value"],
  15.                   '__VIEWSTATEGENERATOR': soup.select_one("#__VIEWSTATEGENERATOR")["value"],
  16.                   'SchSel$cmbUserType': 'Student',
  17.                   'SchSel$txtUserName': 'user',
  18.                   'SchSel$txtPassword': '1234',
  19.                   'SchSel$chkSkip': 'on',
  20.                   'SchSel$hidLastLogin': '2016-2017',
  21.                   'SchSel$hidSchoolId': '1',
  22.                   'SchSel$hidSchoolName': 'School name',
  23.                   'SchSel$hidCoreUserDet': '815106',
  24.                   'SchSel$hidSessionId': '8',
  25.                   'SchSel$hidActiveSchool': '1',
  26.                   'SchSel$hidHitCount': soup.select_one("#lblTotalHit").text.split(":", 1)[1].strip(),
  27.                   'SchSel$hidReportingDet': '0',
  28.                   'SchSel$hidActiveSession': '1',
  29.                   'SchSel$hidSchoolAddress': 'Address',
  30.                   'SchSel$hdnLoginAsUser': '',
  31.                   '__ASYNCPOST': 'true',
  32.                   'SchSel$btnLogin.x': '42',
  33.                   'SchSel$btnLogin.y': '14'
  34.                   }
  35.     s.post(url, data=login_data, headers=headers)
  36.  
  37.     res = s.get('Protected page')
Advertisement
Add Comment
Please, Sign In to add comment