May-19-2018, 06:02 AM
(May-19-2018, 12:01 AM)snippsat Wrote: It's not far fetch it's quite common that you write code to access a web-site. Requests as you mention can be used, but then have to inspect(eg Chrome/FireFoc Dev Tools) to see what going on when login and try replicate it. Selenium is an other way to do it,that can be easier. Example skeleton how it can look in Requests,i took a quick look at login. The form data that is send when reset isMobil=0123456789&Type=2
Type is based on first choice so 2 is Student. You will need Cookie and probably most of header data.import requests headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0', ...... } cookies = { '__RequestVerificationToken':..... ...... } params = { "Mobile":"0123456789", "Type":"2" } with requests.Session() as s: response = s.post('http://www.msmcampuscare.in/Logon/ResetPassword', headers=headers, cookies=cookies, params=params ) print(response.text) # Authorised request. r = s.get('A protected web page url') print(r.text)
Sir, as I am a newbie, a major portion of this code is incomprehensible to me. However, the '.....' that you have used in the cookies dictionary is being shown as syntax error due to not being present in quotes. Am I missing something here?