Python Forum
A crazy project involving webpage interaction
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A crazy project involving webpage interaction
#4
(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 is Mobil=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?
Reply


Messages In This Thread
RE: A crazy project involving webpage interaction - by apsaditya - May-19-2018, 06:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best framework for MySQL interaction and Tensorflow / TFLite inference? f_set89 0 594 Nov-23-2023, 04:14 PM
Last Post: f_set89
  this would be silly if it as not driving mr crazy Blue Dog 16 12,926 Oct-27-2016, 10:21 PM
Last Post: Blue Dog

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020