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.
 
 

25 lines
837 B

from urllib.parse import urlparse
from lxml.html import fromstring as lxml_from_string
from panera_sync.fill_form import get_form_fields
def saml_submit(session, response):
origin_url = response.url
url_parse_result = urlparse(origin_url)
headers = {
"Origin": f"{url_parse_result.scheme}://{url_parse_result.netloc}",
"Referer": origin_url,
}
parsed = lxml_from_string(response.text)
form = parsed.xpath("//form")[0]
post_url, to_submit = get_form_fields(form)
return session.post(post_url, data=to_submit, headers=headers)
def saml_check(session, response, response_text=None):
parsed = lxml_from_string(response.text)
witness = parsed.xpath('//form//input[contains(@name,"SAML")]')
print(witness)
if len(witness) != 0:
return saml_submit(session, response)