import requests
url = "https://www.passendlezen.nl/iguana/Proxy.UserActivities.cls"
r1_headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
'Accept-Encoding': 'gzip, deflate, br',
}
s = requests.session()
r1 = s.post(url, headers=r1_headers)
cookies = r1.cookies
# print(cookies)
cookie_string = "; ".join([str(x)+"="+str(y) for x,y in cookies.items()])
eerste = cookies.items()
alles = str(eerste[1]).split(',')[1].strip(')').split(' ')[1].strip("'")
#print(alles)
id = alles[12:22]
# print(cookie_string)
# print(id)
headers = {'referer': 'https://www.passendlezen.nl/iguana/www.main.cls?sUrl=home',
"SOAPAction": 'CheckCredentials',
'content-type': 'text/xml; charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
'cookie': cookie_string,
#'cookie': 'CSPWSERVERID=C22A9rR3; CSPSESSIONID-SP-443-UP-iguana-=001002050000FN6rFuiQGGungE2IKU4_CFx4Occi_y$8Nm16Zq;'
}
#tussen de + + vervangen voor 'id'
body = """
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body><CheckCredentials><Language>dut</Language><Profile>Iguana</Profile><CspSessionId>""" + id + """</CspSessionId><LogonId>191623</LogonId><Password>test</Password>
</CheckCredentials></SOAP-ENV:Body></SOAP-ENV:Envelope>"""
r2 = s.post(url, data=body, headers=headers, verify=False)
print(r1.cookies)
print(r2.text)
print(r2.status_code)
print(cookie_string)
print(id)