You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
736 B

from lxml.html import fromstring as lxml_from_string
from urllib.parse import urljoin
from panera_sync.saml_check import saml_check
from panera_sync.fill_form import get_form_fields
def login_user(session, response, username, password):
parsed = lxml_from_string(response.text)
form = parsed.xpath("//form")[0]
post_url, to_send = get_form_fields(form)
to_send["username"] = username
to_send["password"] = password
print(to_send)
post_url = urljoin(response.url, post_url)
print(post_url)
headers = {
"Host": "iso3.panerabread.com",
"Referer": "https://pantry.panerabread.com/",
}
r = session.post(post_url, data=to_send, headers=headers)
return saml_check(session, r)