Code:
import os
import time
import json
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, JavascriptException
from webdriver_manager.chrome import ChromeDriverManager

class AviatorScraper:
    def __init__(self):
        self.SCREENSHOT_DIR = "screenshots"
        self.DATA_DIR = "data"
        self.MAX_WAIT = 30
        self.multipliers = []
        self.driver = None
        
        for directory in [self.SCREENSHOT_DIR, self.DATA_DIR]:
            if not os.path.exists(directory):
                os.makedirs(directory)

    def setup_driver(self):
        options = webdriver.ChromeOptions()
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')
        options.add_argument('--window-size=1920,1080')
        self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
        self.wait = WebDriverWait(self.driver, self.MAX_WAIT)

    def login(self):
        self.driver.get("https://betika.com/en-ke/login")
        print("Opened Betika login page.")

        try:
            close_modal_button = self.wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.close-modal")))
            close_modal_button.click()
            print("Closed modal.")
        except TimeoutException:
            print("No modal to close.")

        login_steps = [
            {
                'selector': "div.session__form__input.session__form__phone input.input",
                'action': lambda elem: elem.send_keys("0703972766"),
                'message': "Entered phone number"
            },
            {
                'selector': "div.session__form__input.session__form__password input.input",
                'action': lambda elem: elem.send_keys("ComplexPass123!"),
                'message': "Entered password"
            },
            {
                'selector': "button.session__form__button.login.button.button__secondary",
                'action': lambda elem: elem.click(),
                'message': "Clicked login button"
            }
        ]

        for step in login_steps:
            element = self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, step['selector'])))
            step['action'](element)
            print(step['message'])

    def navigate_to_aviator(self):
        time.sleep(5)
        self.driver.get("https://betika.com/en-ke/aviator")
        print("Navigated to Aviator page.")
        time.sleep(10)

    def analyze_iframe(self, iframe_element):
        try:
            self.driver.switch_to.frame(iframe_element)
            
            # Wait for and observe multiple rounds
            rounds_data = []
            start_time = time.time()
            observation_time = 300  # 5 minutes

            while time.time() - start_time < observation_time:
                try:
                    # Use JavaScript to find multipliers
                    js_script = """
                    return Array.from(document.querySelectorAll('*'))
                        .filter(el => el.textContent.match(/^\\d+(\\.\\d+)?x$/))
                        .map(el => ({
                            multiplier: el.textContent,
                            timestamp: new Date().toISOString()
                        }));
                    """
                    new_multipliers = self.driver.execute_script(js_script)
                    
                    if new_multipliers:
                        rounds_data.extend(new_multipliers)
                        print(f"Found new multiplier: {new_multipliers[-1]['multiplier']}")
                    
                    time.sleep(5)  # Wait for next round
                    
                except JavascriptException as je:
                    print(f"JavaScript error: {je}")
                    continue

            return rounds_data

        finally:
            self.driver.switch_to.default_content()

    def save_data(self, rounds_data):
        timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
        filename = f'aviator_data_{timestamp}.json'
        filepath = os.path.join(self.DATA_DIR, filename)
        
        with open(filepath, 'w') as f:
            json.dump(rounds_data, f, indent=2)
        
        print(f"Saved data to {filepath}")
        return filepath

    def scrape(self):
        try:
            self.setup_driver()
            self.login()
            self.navigate_to_aviator()

            iframes = self.driver.find_elements(By.TAG_NAME, "iframe")
            print(f"Found {len(iframes)} iframes on the page.")

            all_rounds_data = []
            
            for index, iframe in enumerate(iframes):
                iframe_src = iframe.get_attribute("src")
                if "spribegaming" in iframe_src.lower():
                    print(f"Analyzing game iframe {index}")
                    rounds_data = self.analyze_iframe(iframe)
                    if rounds_data:
                        all_rounds_data.extend(rounds_data)
                        break

            if all_rounds_data:
                filepath = self.save_data(all_rounds_data)
                self.analyze_results(all_rounds_data, filepath)
            else:
                print("No multipliers found during observation period.")

        except Exception as e:
            print(f"An error occurred during scraping: {e}")
            self.driver.save_screenshot(os.path.join(self.SCREENSHOT_DIR, "error_screenshot.png"))
        
        finally:
            if self.driver:
                self.driver.quit()

    @staticmethod
    def analyze_results(rounds_data, filepath):
        multipliers = [float(round_data['multiplier'].rstrip('x')) for round_data in rounds_data]
        
        if multipliers:
            avg_multiplier = sum(multipliers) / len(multipliers)
            max_multiplier = max(multipliers)
            min_multiplier = min(multipliers)
            
            print("\nResults Analysis:")
            print(f"Total rounds recorded: {len(multipliers)}")
            print(f"Average multiplier: {avg_multiplier:.2f}x")
            print(f"Highest multiplier: {max_multiplier:.2f}x")
            print(f"Lowest multiplier: {min_multiplier:.2f}x")
            print(f"Data saved to: {filepath}")

def main():
    scraper = AviatorScraper()
    scraper.scrape()

if __name__ == "__main__":
    main()

Code output:
Opened Betika login page.
No modal to close.
Entered phone number
Entered password
Clicked login button
Navigated to Aviator page.
Found 11 iframes on the page.
Analyzing game iframe 0
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 2881.31x
Found new multiplier: 2881.31x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Found new multiplier: 453.94x
Saved data to data\aviator_data_20241005_005151.json

Results Analysis:
Total rounds recorded: 620
Average multiplier: 2113.95x
Highest multiplier: 2881.31x
Lowest multiplier: 453.94x
Data saved to: data\aviator_data_20241005_005151.json


The multiplier values are not the same as the ones in the website.