Я хочу войти в HotSchedules и вернуться на страницу после входа в систему. Прямо сейчас он просто возвращает страницу входа в систему.
import requests, lxml.html
s = requests.session()
### Here, we're getting the login page and then grabbing hidden form
### fields. We're probably also getting several session cookies too.
login = s.get('https://app.hotschedules.com/hs/login.jsp')
login_html = lxml.html.fromstring(login.text)
hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]')
form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs}
print(form)
{'csrftok': '3b16f549-0712-49d8-8f1c-afda13be75ce',
'context': ''}
### Now that we have the hidden form fields, let's add in our
### username and password.
form['loginusername'] = "USERNAME"# Enter an email here. Not mine.
form['loginpassword'] = "PASSWORD"# I'm definitely not telling you my password.
response = s.post('https://app.hotschedules.com/hs/login.jsp', data=form)
### How can we tell that we logged in? Well, these worked for me:
print (response.url)
response.url
'https://app.hotschedules.com/hs/menuParser.hs?screen=employeeHome#/home'
'Chili' in response.text
print (response.text)
True
Он должен просто войти в систему, но он возвращает страницу входа в систему.