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

  1. from lxml.html import fromstring as lxml_from_string
  2. from urllib.parse import urljoin
  3. from panera_sync.saml_check import saml_check
  4. from panera_sync.fill_form import get_form_fields
  5. def login_user(session, response, username, password):
  6. parsed = lxml_from_string(response.text)
  7. form = parsed.xpath("//form")[0]
  8. post_url, to_send = get_form_fields(form)
  9. to_send["username"] = username
  10. to_send["password"] = password
  11. print(to_send)
  12. post_url = urljoin(response.url, post_url)
  13. print(post_url)
  14. headers = {
  15. "Host": "iso3.panerabread.com",
  16. "Referer": "https://pantry.panerabread.com/",
  17. }
  18. r = session.post(post_url, data=to_send, headers=headers)
  19. return saml_check(session, r)