-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ssid refresher with crf bypass
- Loading branch information
1 parent
cc35099
commit 9982906
Showing
7 changed files
with
72 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
"""Module for Quotex http login resource.""" | ||
"""Module for Quotex http logout resource.""" | ||
|
||
from quotexpy.http.navigator import Navigator | ||
|
||
|
||
class Logout(Navigator): | ||
"""Class for Quotex login resource.""" | ||
|
||
base_url = "qxbroker.com" | ||
https_base_url = f"https://{base_url}" | ||
|
||
def _post(self, data=None, headers=None): | ||
"""Send get request for Quotex API login http resource. | ||
:returns: The instance of :class:`navigator.Session`. | ||
""" | ||
return self.send_request(method="POST", url=f"{self.https_base_url}/logout", data=data, headers=headers) | ||
"""Class for Quotex logout resource.""" | ||
|
||
def __call__(self): | ||
return self._post() | ||
response = self.send_request( | ||
method="GET", | ||
url=f"{self.https_base_url}/logout", | ||
headers={"User-Agent": self.api.user_agent, "Cookie": self.api.cookies}, | ||
) | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,28 @@ | ||
import random | ||
import requests | ||
from bs4 import BeautifulSoup | ||
from urllib3.util.retry import Retry | ||
from requests.adapters import HTTPAdapter | ||
|
||
from quotexpy.http.user_agents import agents | ||
|
||
retry_strategy = Retry( | ||
total=3, | ||
backoff_factor=1, | ||
status_forcelist=[429, 500, 502, 503, 504, 104], | ||
allowed_methods=["HEAD", "POST", "PUT", "GET", "OPTIONS"], | ||
) | ||
|
||
adapter = HTTPAdapter(max_retries=retry_strategy) | ||
user_agent_list = agents.split("\n") | ||
|
||
|
||
class Navigator(object): | ||
def __init__(self, api): | ||
""" | ||
Tools for quotexpy navigation. | ||
:param object api: The instance of :class:`quotexpy.api.QuotexAPI`. | ||
""" | ||
"""Tools for quotexpy navigation.""" | ||
self.base_url = "qxbroker.com" | ||
self.https_base_url = f"https://{self.base_url}" | ||
|
||
self.api = api | ||
self.response = None | ||
self.headers = self.get_headers() | ||
self.session = requests.Session() | ||
self.api.user_agent = self.headers["User-Agent"] | ||
self.session.mount("http://", adapter) | ||
self.session.mount("https://", adapter) | ||
|
||
def get_headers(self): | ||
self.headers = { | ||
"User-Agent": user_agent_list[random.randint(0, len(user_agent_list) - 1)], | ||
} | ||
retry_strategy = Retry( | ||
total=3, | ||
backoff_factor=1, | ||
status_forcelist=[429, 500, 502, 503, 504, 104], | ||
allowed_methods=["HEAD", "POST", "PUT", "GET", "OPTIONS"], | ||
) | ||
|
||
return self.headers | ||
adapter = HTTPAdapter(max_retries=retry_strategy) | ||
|
||
def get_soup(self): | ||
return BeautifulSoup(self.response.content, "html.parser") | ||
self.session.mount("http://", adapter) | ||
self.session.mount("https://", adapter) | ||
|
||
def send_request(self, method, url, **kwargs): | ||
self.response = self.session.request(method, url, headers=self.headers, **kwargs) | ||
return self.response | ||
def send_request(self, method: str, url: str, headers: dict, **kwargs): | ||
return self.session.request(method, url, headers=headers, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Module for Quotex http refresh ssid resource.""" | ||
|
||
from quotexpy.http.navigator import Navigator | ||
|
||
|
||
class Refresh(Navigator): | ||
"""Class for Quotex refresh resource.""" | ||
|
||
def __call__(self): | ||
try: | ||
response = self.send_request( | ||
method="GET", | ||
url=f"{self.https_base_url}/api/v1/cabinets/digest", | ||
headers={"User-Agent": self.api.user_agent, "Cookie": self.api.cookies}, | ||
) | ||
|
||
if response.status_code == 200: | ||
response_json: dict = response.json() | ||
data: dict = response_json.get("data") | ||
if data and data.get("token"): | ||
return data.get("token") | ||
else: | ||
raise KeyError("token not found in response data") | ||
else: | ||
raise ValueError("error refreshing ssid, maybe your client started without credentials?") | ||
except Exception as err: | ||
raise RuntimeError(f"unhandled error: {str(err)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pytest==7.4.2 | ||
black==23.9.1 | ||
poetry==1.6.1 | ||
pylint==2.17.5 | ||
pytest==7.4.2 | ||
termcolor==2.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
psutil | ||
beautifulsoup4==4.11.2 | ||
certifi>=2022.12.7 | ||
greenlet>=3.0.3 | ||
undetected-chromedriver>=3.5.5 | ||
pytz>=2023.3 | ||
requests>=2.32.3 | ||
requests-toolbelt>=1.0.0 | ||
urllib3>=2.2.2 | ||
websockets>=12 | ||
greenlet>=3.0.3 | ||
requests>=2.32.3 | ||
certifi>=2022.12.7 | ||
websocket-client>=1.8 | ||
websockets>=12 | ||
requests-toolbelt>=1.0.0 | ||
undetected-chromedriver>=3.5.5 |