Changed SI check. Changed qr code image sending

This commit is contained in:
Joan
2023-10-16 12:51:55 +02:00
parent db25837ebc
commit 293bfd4e81

View File

@@ -60,14 +60,15 @@ def whatsapp_login(driver):
while True:
response = requests.get(f"{REQUEST_URL}/abresesion.php")
logging.info("Checking if someones there...")
if response.content == "SI":
if "SI" in response.content:
logging.info("Someones there! Getting QR code...")
driver.get("https://web.whatsapp.com/")
time.sleep(SLEEP_LONG)
driver.save_screenshot(location)
with open(location, "rb") as qrcode:
encoded_string = base64.b64encode(qrcode.read())
requests.post(f"{REQUEST_URL}/qrsesion.php", data=encoded_string)
files = {'qr_image': qrcode}
#encoded_string = base64.b64encode(qrcode.read())
requests.post(f"{REQUEST_URL}/qrsesion.php", files=files)
logging.info("QR code sent through POST request! Waiting for user to scan it")
time.sleep(SLEEP_QRCODE)
driver.get("https://web.whatsapp.com/")