-
Notifications
You must be signed in to change notification settings - Fork 66
[WIP] Update get_ssid.py script for improved SSID retrieval #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,126 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # PocketOption Tools | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| This directory contains utility tools for working with the PocketOption API. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ## get_ssid.py - SSID Extraction Tool | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| This tool automatically extracts your PocketOption session ID (SSID) by monitoring WebSocket traffic during login. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### What is SSID? | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| SSID (Session ID) is the authentication token required to use the PocketOption API. It's a string that looks like: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42["auth",{"session":"your-session-here","isDemo":1,"uid":12345,"platform":1}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Prerequisites | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Before running the tool, make sure you have the required dependencies installed: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pip install -r requirements.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| The tool requires: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - `selenium>=4.0.0` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - `webdriver-manager>=4.0.0` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - Chrome browser installed on your system | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### How to Use | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. **Navigate to the tools directory:** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cd tools | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. **Run the script:** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| python get_ssid.py | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. **Follow the on-screen instructions:** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - A Chrome browser window will open automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - Navigate to the PocketOption login page | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - Log in with your credentials | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - Wait for the automatic redirection to the trading cabinet | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - The script will automatically extract and save your SSID | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 4. **Find your SSID:** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - The SSID will be saved to a `.env` file in the current directory | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - You can now use this SSID in your API scripts | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Expected Output | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| When successful, you'll see: | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - ================================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - PocketOption SSID Extractor Tool | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - ================================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - INSTRUCTIONS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - 1. A Chrome browser will open shortly | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - 2. Please log in to PocketOption with your credentials | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:31:45 - INFO - Found valid SSID string in WebSocket payload | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:31:45 - INFO - ================================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:31:45 - INFO - SUCCESS! SSID successfully extracted and saved to .env file. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:31:45 - INFO - You can now use this SSID in your PocketOption API scripts. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:31:45 - INFO - ================================================================================ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+69
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025-12-25 10:30:15 - INFO - ================================================================================ | |
| 2025-12-25 10:30:15 - INFO - PocketOption SSID Extractor Tool | |
| 2025-12-25 10:30:15 - INFO - ================================================================================ | |
| 2025-12-25 10:30:15 - INFO - INSTRUCTIONS: | |
| 2025-12-25 10:30:15 - INFO - 1. A Chrome browser will open shortly | |
| 2025-12-25 10:30:15 - INFO - 2. Please log in to PocketOption with your credentials | |
| ... | |
| 2025-12-25 10:31:45 - INFO - Found valid SSID string in WebSocket payload | |
| 2025-12-25 10:31:45 - INFO - ================================================================================ | |
| 2025-12-25 10:31:45 - INFO - SUCCESS! SSID successfully extracted and saved to .env file. | |
| 2025-12-25 10:31:45 - INFO - You can now use this SSID in your PocketOption API scripts. | |
| 2025-12-25 10:31:45 - INFO - ================================================================================ | |
| YYYY-MM-DD HH:MM:SS - INFO - ================================================================================ | |
| YYYY-MM-DD HH:MM:SS - INFO - PocketOption SSID Extractor Tool | |
| YYYY-MM-DD HH:MM:SS - INFO - ================================================================================ | |
| YYYY-MM-DD HH:MM:SS - INFO - INSTRUCTIONS: | |
| YYYY-MM-DD HH:MM:SS - INFO - 1. A Chrome browser will open shortly | |
| YYYY-MM-DD HH:MM:SS - INFO - 2. Please log in to PocketOption with your credentials | |
| ... | |
| YYYY-MM-DD HH:MM:SS - INFO - Found valid SSID string in WebSocket payload | |
| YYYY-MM-DD HH:MM:SS - INFO - ================================================================================ | |
| YYYY-MM-DD HH:MM:SS - INFO - SUCCESS! SSID successfully extracted and saved to .env file. | |
| YYYY-MM-DD HH:MM:SS - INFO - You can now use this SSID in your PocketOption API scripts. | |
| YYYY-MM-DD HH:MM:SS - INFO - ================================================================================ |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,11 +9,11 @@ | |||||||||||||||||||
| from driver import get_driver | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Configure logging for this script to provide clear, structured output. | ||||||||||||||||||||
| # Logs will be directed to standard output, making them compatible with containerization | ||||||||||||||||||||
| # and centralized log collection systems. | ||||||||||||||||||||
| # Using a simpler format for better readability by end users. | ||||||||||||||||||||
| logging.basicConfig( | ||||||||||||||||||||
| level=logging.INFO, | ||||||||||||||||||||
| format='{"timestamp": "%(asctime)s", "level": "%(levelname)s", "module": "%(name)s", "message": "%(message)s"}', | ||||||||||||||||||||
| format='%(asctime)s - %(levelname)s - %(message)s', | ||||||||||||||||||||
| datefmt='%Y-%m-%d %H:%M:%S' | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -57,26 +57,47 @@ def get_pocketoption_ssid(): | |||||||||||||||||||
| Automates the process of logging into PocketOption, navigating to a specific cabinet page, | ||||||||||||||||||||
| and then scraping WebSocket traffic to extract the session ID (SSID). | ||||||||||||||||||||
| The extracted SSID is then saved to the .env file. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Instructions: | ||||||||||||||||||||
| 1. Run this script | ||||||||||||||||||||
| 2. A Chrome browser will open and navigate to PocketOption login page | ||||||||||||||||||||
| 3. Log in manually with your credentials | ||||||||||||||||||||
| 4. Wait for the script to automatically extract your SSID | ||||||||||||||||||||
| 5. The SSID will be saved to .env file in the current directory | ||||||||||||||||||||
| """ | ||||||||||||||||||||
| driver = None | ||||||||||||||||||||
| try: | ||||||||||||||||||||
| logger.info("=" * 80) | ||||||||||||||||||||
| logger.info("PocketOption SSID Extractor Tool") | ||||||||||||||||||||
| logger.info("=" * 80) | ||||||||||||||||||||
| logger.info("INSTRUCTIONS:") | ||||||||||||||||||||
| logger.info("1. A Chrome browser will open shortly") | ||||||||||||||||||||
| logger.info("2. Please log in to PocketOption with your credentials") | ||||||||||||||||||||
| logger.info("3. Wait for automatic redirection to the trading cabinet") | ||||||||||||||||||||
| logger.info("4. The script will extract your SSID automatically") | ||||||||||||||||||||
| logger.info("=" * 80) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Initialize the Selenium WebDriver using the helper function from driver.py. | ||||||||||||||||||||
| # This ensures the browser profile is persistent for easier logins. | ||||||||||||||||||||
| driver = get_driver("chrome") | ||||||||||||||||||||
| login_url = "https://pocketoption.com/en/login" | ||||||||||||||||||||
| cabinet_base_url = "https://pocketoption.com/en/cabinet" | ||||||||||||||||||||
| target_cabinet_url = "https://pocketoption.com/en/cabinet/demo-quick-high-low/" | ||||||||||||||||||||
| # Regex to capture the entire "42[\"auth\",{...}]" string. | ||||||||||||||||||||
| # This pattern is designed to be robust and capture the full authentication message, | ||||||||||||||||||||
| # regardless of the specific content of the 'session' field (e.g., simple string or serialized PHP array). | ||||||||||||||||||||
| ssid_pattern = r'(42\["auth",\{"session":"[^"]+","isDemo":\d+,"uid":\d+,"platform":\d+,"isFastHistory":(?:true|false)\}\])' | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Flexible regex pattern to capture auth messages in various formats | ||||||||||||||||||||
| # This pattern handles: | ||||||||||||||||||||
| # - Optional isFastHistory field | ||||||||||||||||||||
| # - Any field order in the JSON object | ||||||||||||||||||||
| # - Various session string formats | ||||||||||||||||||||
| ssid_pattern = r'42\["auth",(\{(?:[^{}]|\{[^}]*\})*\})\]' | ||||||||||||||||||||
|
Comment on lines
+88
to
+92
|
||||||||||||||||||||
| # This pattern handles: | |
| # - Optional isFastHistory field | |
| # - Any field order in the JSON object | |
| # - Various session string formats | |
| ssid_pattern = r'42\["auth",(\{(?:[^{}]|\{[^}]*\})*\})\]' | |
| # This pattern now captures the entire JSON payload after 42["auth", | |
| # and relies on json.loads to correctly parse any nested objects. | |
| # It matches messages of the form: 42["auth",<json>] | |
| ssid_pattern = r'42\["auth",(.*)\]' |
Copilot
AI
Dec 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging level is set to INFO (line 14), but this code uses logger.debug() at lines 148 and 174. These debug messages will never be displayed to users. Either change these to logger.info() if the information is useful for users, or consider making the logging level configurable if you want to support debug output.
Copilot
AI
Dec 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging level is set to INFO (line 14), but this code uses logger.debug(). This debug message will never be displayed to users. Either change this to logger.info() if the information is useful, or consider making the logging level configurable.
| logger.debug(f"Error processing log entry: {e}") | |
| logger.info(f"Error processing log entry: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an inconsistency in the instructions. Step 3 says "Navigate to the PocketOption login page" but the script automatically navigates to the login page (line 95 in the code:
driver.get(login_url)). The instruction should say "The browser will automatically navigate to the PocketOption login page" or similar to reflect the actual behavior.