|
|
|
@ -1,19 +1,27 @@ |
|
|
|
from lxml.html import fromstring as lxml_from_string |
|
|
|
from urllib.parse import urljoin |
|
|
|
|
|
|
|
import requests |
|
|
|
from panera_sync.saml_check import saml_check |
|
|
|
from panera_sync.fill_form import get_form_fields |
|
|
|
|
|
|
|
PANERA_URL = "https://pantry.panerabread.com" |
|
|
|
|
|
|
|
|
|
|
|
def get_login_page(session: requests.Session): |
|
|
|
landing = session.get(PANERA_URL) |
|
|
|
return saml_check(session, landing) |
|
|
|
|
|
|
|
def login_user(session, response, username, password): |
|
|
|
|
|
|
|
def login_user(session, username, password): |
|
|
|
response = get_login_page(session) |
|
|
|
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/", |
|
|
|
|