From c25035b636f90f6ae6e53bb771e9ed1d991ccca6 Mon Sep 17 00:00:00 2001 From: Santiago Ramirez Date: Sun, 21 Jul 2024 16:42:35 -0400 Subject: [PATCH] handler if pin code is invalid --- example/main.py | 8 +------- quotexpy/http/qxbroker.py | 10 +++++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/example/main.py b/example/main.py index fc03be8..5cbb99c 100644 --- a/example/main.py +++ b/example/main.py @@ -80,13 +80,7 @@ def run(y): return z -client = Quotex( - email="", - password="", - on_pin_code=pin_code_handler, - headless=False, -) - +client = Quotex(email="", password="", on_pin_code=pin_code_handler) client.debug_ws_enable = False diff --git a/quotexpy/http/qxbroker.py b/quotexpy/http/qxbroker.py index f3c0db2..62224ec 100644 --- a/quotexpy/http/qxbroker.py +++ b/quotexpy/http/qxbroker.py @@ -1,11 +1,12 @@ import os import re import json -import pickle import time +import pickle import typing import random import psutil +import random import requests from pathlib import Path from bs4 import BeautifulSoup @@ -46,7 +47,6 @@ def get_cookies_and_ssid(self) -> typing.Tuple[str, str]: rb = self.browser.execute_script('return document.querySelector(".modal-sign__not-avalible") !== null;') if rb: - self.close() raise ConnectionError("quotex is currently not available in your region") if "trade" not in self.browser.current_url: @@ -71,7 +71,11 @@ def get_cookies_and_ssid(self) -> typing.Tuple[str, str]: self.browser.execute_script('document.querySelector("[name=code]").value = arguments[0];', code) btn = self.browser.find_element(uc.By.XPATH, "//button[@type='submit']") btn.click() - time.sleep(10) + + time.sleep(random.randint(2, 4)) + bc = self.browser.execute_script('return document.querySelector(".hint.hint--danger") !== null;') + if bc: + raise QuotexAuthError("the pin code is incorrect") cookies = self.browser.get_cookies() self.api.cookies = cookies