I have a script in which I am getting Syntex errors. kindly fix them and provide me full updated script. here is my script=# Install Required Libraries
!pip install selenium webdriver-manager validators

# Import Necessary Libraries
import os
import ipywidgets as widgets
from IPython.display import display, clear_output
from ipywidgets import Layout, VBox, HBox
from google.colab import drive
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import TimeoutException, NoSuchElementException
import validators  # For URL validation

# Mount Google Drive to Access Files
drive.mount('/content/drive')

# Function to Set Up Selenium WebDriver
def setup_webdriver():
    """
    Sets up the Selenium WebDriver with Chrome options.
    Returns:
        driver (webdriver.Chrome): Configured WebDriver instance.
    """
    options = webdriver.ChromeOptions()
    options.add_argument("--verbose")
    options.add_argument("--no-sandbox")
    options.add_argument("--headless")  # Uncomment for non-headless mode (for debugging)
    options.add_argument("--disable-gpu")
    options.add_argument("--window-size=1920,1200")
    options.add_argument("--disable-dev-shm-usage")
    
    # Initialize WebDriver using WebDriver Manager
    service = Service(ChromeDriverManager().install())
    driver = webdriver.Chrome(service=service, options=options)
    return driver

# Initialize WebDriver Variable
driver = None

# Create UI Components

# Widget to Select Zip File from Google Drive
input_zip_widget = widgets.Select(
    options=[],
    description='Input Zip File:',
    disabled=False,
    layout=Layout(width='100%', height='200px')
)

# Button to Refresh the List of Zip Files
refresh_button = widgets.Button(
    description='Refresh Zip Files List',
    disabled=False,
    button_style='info',
    tooltip='Click to refresh the list of zip files',
    icon='refresh'
)

# Text Widget for Username (Empty by Default for Security)
username_widget = widgets.Text(
    value='',  # Empty by default
    placeholder='Enter your username',
    description='Username:',
    disabled=False,
    layout=Layout(width='auto')
)

# Password Widget for Password (Empty by Default for Security)
password_widget = widgets.Password(
    value='',  # Empty by default
    placeholder='Enter your password',
    description='Password:',
    disabled=False,
    layout=Layout(width='auto')
)

# Text Widget for File Path (Optional)
file_path_widget = widgets.Text(
    value='',
    placeholder='Enter the path to your zip file in Colab',
    description='File Path:',
    disabled=False,
    layout=Layout(width='auto')
)

# Text Widget for Output Directory with Default Path
output_dir_widget = widgets.Text(
    value='/content/drive/MyDrive/UploadLinks',
    placeholder='Enter output directory path',
    description='Output Dir:',
    disabled=False,
    layout=Layout(width='auto')
)

# Button to Start the Upload Process
start_upload_button = widgets.Button(
    description='Start Upload',
    disabled=False,
    button_style='success',
    tooltip='Click to start uploading the selected zip file',
    icon='upload'
)

# Output Widget to Display Logs and Messages
output = widgets.Output()

# Helper Function to Find Elements with Multiple Selector Strategies
def find_element(driver, selectors, timeout=10):
    """
    Attempts to locate a web element using a list of selector strategies.
    
    Args:
        driver (webdriver.Chrome): Selenium WebDriver instance.
        selectors (list): List of tuples containing (By, selector).
        timeout (int): Maximum time to wait for the element.
    
    Returns:
        element (WebElement): Located web element.
    
    Raises:
        NoSuchElementException: If the element is not found using any of the selectors.
    """
    for selector in selectors:
        try:
            element = WebDriverWait(driver, timeout).until(
                EC.presence_of_element_located(selector)
            )
            return element
        except TimeoutException:
            continue
    raise NoSuchElementException(f"Element not found using selectors: {selectors}")

# Function to Update the List of Zip Files from Google Drive
def update_zip_files(b):
    """
    Refreshes the list of zip files available in the specified Google Drive directory.
    
    Args:
        b: Button click event (unused).
    """
    with output:
        clear_output()
        print("Refreshing the list of zip files...")
        drive_root = '/content/drive/MyDrive/'  # Modify this path as needed
        zip_files = []
        for root, dirs, files in os.walk(drive_root):
            for file in files:
                if file.lower().endswith('.zip'):
                    full_path = os.path.join(root, file)
                    zip_files.append(full_path)
        if zip_files:
            input_zip_widget.options = zip_files
            print(f"Found {len(zip_files)} zip file(s) in {drive_root}.")
        else:
            input_zip_widget.options = []
            print(f"No zip files found in {drive_root}.")

# Function to Start the Upload Process
def start_upload(b):
    """
    Automates the process of uploading a zip file to dupload.net.
    
    Args:
        b: Button click event (unused).
    """
    global driver
    with output:
        clear_output()
        # Retrieve User Inputs
        selected_zip = input_zip_widget.value
        username = username_widget.value.strip()
        password = password_widget.value.strip()
        file_path = file_path_widget.value.strip()
        output_dir = output_dir_widget.value.strip()
        
        # Input Validation
        if not selected_zip and not file_path:
            print("No zip file selected and no file path provided. Please select a zip file or enter a valid file path.")
            return
        if not username or not password:
            print("Username and password cannot be empty.")
            return
        if not output_dir:
            print("Output directory path cannot be empty.")
            return
        
        # Determine the Zip File Path
        if selected_zip:
            zip_path = selected_zip
        else:
            zip_path = file_path
            if not os.path.isfile(zip_path):
                print(f"The file at {zip_path} does not exist.")
                return
        
        # Ensure the Output Directory Exists
        if not os.path.exists(output_dir):
            try:
                os.makedirs(output_dir)
                print(f"Created output directory at {output_dir}.")
            except Exception as e:
                print(f"Failed to create output directory at {output_dir}: {e}")
                return
        
        # Setup WebDriver
        print("Setting up the WebDriver...")
        try:
            driver = setup_webdriver()
            print("WebDriver setup completed.")
        except Exception as e:
            print(f"Failed to initialize WebDriver: {e}")
            return
        
        try:
            # Navigate to the Login Page
            print("Navigating to the login page...")
            driver.get("https://dupload.net/login.html")
            
            # ENTER USERNAME
            try:
                username_selectors = [
                    (By.NAME, "login"),
                    (By.XPATH, "//input[@placeholder='Username']"),
                    (By.CSS_SELECTOR, "input.form-control")
                ]
                username_field = find_element(driver, username_selectors)
                username_field.clear()
                username_field.send_keys(username)
                print("Entered username.")
            except NoSuchElementException as e:
                print(f"Username input field not found: {e}")
                return
            
            # ENTER PASSWORD
            try:
                password_selectors = [
                    (By.NAME, "password"),
                    (By.XPATH, "//input[@placeholder='Password']"),
                    (By.CSS_SELECTOR, "input[type='password']")
                ]
                password_field = find_element(driver, password_selectors)
                password_field.clear()
                password_field.send_keys(password)
                print("Entered password.")
            except NoSuchElementException as e:
                print(f"Password input field not found: {e}")
                return
            
            # CLICK "LOG IN" BUTTON
            try:
                login_button_selectors = [
                    (By.CSS_SELECTOR, "button.btn.btn-primary[type='submit']"),
                    (By.XPATH, "//button[contains(text(), 'Log in')]"),
                    (By.XPATH, "//button[@type='submit' and @value='Submit']")
                ]
                login_button = find_element(driver, login_button_selectors)
                login_button.click()
                print("Clicked 'Log in' button.")
            except NoSuchElementException as e:
                print(f"'Log in' button not found: {e}")
                return
            
            # CLICK "UPLOAD FILES" LINK
            try:
                upload_files_selectors = [
                    (By.CSS_SELECTOR, "a[href='https://dupload.net/?op=upload_form']"),
                    (By.XPATH, "//a[contains(text(), 'Upload Files')]"),
                    (By.XPATH, "//a[@href='https://dupload.net/?op=upload_form']")
                ]
                upload_files_link = find_element(driver, upload_files_selectors)
                upload_files_link.click()
                print("Clicked 'Upload Files' link.")
            except NoSuchElementException as e:
                print(f"'Upload Files' link not found: {e}")
                return
            
            # CHOOSE FILE
            try:
                file_input_selectors = [
                    (By.ID, "file_0"),
                    (By.XPATH, "//input[@type='file' and @id='file_0']"),
                    (By.CSS_SELECTOR, "input.uploadbtn.hidden")
                ]
                choose_file_input = find_element(driver, file_input_selectors)
                
                # OPTIONAL: Remove 'hidden' class to make the input visible (if necessary)
                try:
                    driver.execute_script("arguments[0].classList.remove('hidden');", choose_file_input)
                    print("Removed 'hidden' class from the file input.")
                except Exception as e:
                    print(f"Could not remove 'hidden' class: {e}")
                
                # Upload the File by Sending the File Path
                choose_file_input.send_keys(zip_path)
                print(f"Selected file: {zip_path}")
            except NoSuchElementException as e:
                print(f"'Choose File' input not found: {e}")
                return
            
            # CLICK 'START UPLOAD' BUTTON
            try:
                start_upload_selectors = [
                    (By.XPATH, "//button[contains(text(),'Start Upload') or @id='start-upload']"),
                    (By.CSS_SELECTOR, "button.upload-start")
                ]
                start_upload_button_element = find_element(driver, start_upload_selectors)
                start_upload_button_element.click()
                print("Clicked 'Start Upload' button. Upload initiated...")
            except NoSuchElementException as e:
                print(f"'Start Upload' button not found: {e}")
                return
            
            # CLICK "START UPLOADING" BUTTON
            try:
                start_uploading_selectors = [
                    (By.CSS_SELECTOR, "button[name='upload']"),
                    (By.XPATH, "//button[contains(text(), 'Start uploading')]"),
                    (By.XPATH, "//button[@type='button' and @name='upload']"),
                    (By.XPATH, "//button[contains(@class, 'btn-white') and @name='upload']")
                ]
                start_uploading_button = find_element(driver, start_uploading_selectors)
                start_uploading_button.click()
                print("Clicked 'Start uploading' button.")
            except NoSuchElementException as e:
                print(f"'Start uploading' button not found: {e}")
                return
            
            # WAIT FOR UPLOAD TO COMPLETE AND RETRIEVE DOWNLOAD LINK
            print("Waiting for the upload to complete...")
            download_link = None  # Initialize variable to store the download link
            try:
                # **Option 1: Wait for the Download Link from Input Element**
                download_link_selectors = [
                    (By.CSS_SELECTOR, "input.download-link"),
                    (By.XPATH, "//input[@id='download-link']")  # Adjust if different
                ]
                download_link_element = WebDriverWait(driver, 300).until(
                    EC.presence_of_element_located(download_link_selectors[0])  # Prioritize the first selector
                )
                download_link = download_link_element.get_attribute("value")
                print("Upload completed. Retrieved the download link from input element.")
                
                # **Option 2: Wait for the Success Message**
                try:
                    success_message_selectors = [
                        (By.XPATH, "//h1[contains(text(), 'Well Done! Your files are successfully uploaded!')]"),
                        (By.CSS_SELECTOR, "h1.page-title.text-center"),
                    ]
                    success_message_element = WebDriverWait(driver, 300).until(
                        EC.presence_of_element_located(success_message_selectors[0])
                    )
                    success_text = success_message_element.text.strip()
                    if "Well Done! Your files are successfully uploaded!" in success_text:
                        print("Verified success message: Upload was successful.")
                    else:
                        print("Success message not as expected.")
                except TimeoutException:
                    print("Timed out waiting for the success message.")
                except NoSuchElementException as e:
                    print(f"Success message element not found: {e}")
                
                # **Option 3: Retrieve the Download Link from the <a> Tag**
                try:
                    # Define possible selectors for the <a> download link
                    download_a_selectors = [
                        (By.CSS_SELECTOR, "a.download[href^='https://dupload.net/']"),
                        (By.XPATH, "//a[contains(@href, 'dupload.net/') and contains(text(), 'Download')]"),
                        (By.CSS_SELECTOR, "a[href*='dupload.net/'][class='download']")
                    ]
                    download_a_element = WebDriverWait(driver, 60).until(  # Shorter timeout for this step
                        EC.presence_of_element_located(download_a_selectors[0])  # Prioritize the first selector
                    )
                    download_a_href = download_a_element.get_attribute("href")
                    
                    # Validate the link starts with 'https://dupload.net/'
                    if download_a_href.startswith("https://dupload.net/"):
                        print(f"Download link found: {download_a_href}")
                        # Optionally, you can prioritize this link over the download link from the input
                        download_link = download_a_href
                    else:
                        print("Download link does not start with 'https://dupload.net/'.")
                except TimeoutException:
                    print("Timed out waiting for the download <a> link.")
                except NoSuchElementException as e:
                    print(f"Download <a> link not found: {e}")
                
            except TimeoutException:
                print("Timed out waiting for the download link.")
                return
            except NoSuchElementException as e:
                print(f"Download link element not found: {e}")
                return
            
            # VERIFY DOWNLOAD LINK EXISTS AND SAVE IT
            if download_link:
                # Validate the download link format
                if validators.url(download_link) and download_link.startswith("https://dupload.net/"):
                    # SAVE DOWNLOAD LINK TO TEXT FILE
                    zip_file_name = os.path.basename(zip_path)
                    link_file_name = f"{os.path.splitext(zip_file_name)[0]}_upload_link.txt"
                    link_file_path = os.path.join(output_dir, link_file_name)
                    try:
                        with open(link_file_path, "w") as f:
                            f.write(download_link)
                        print(f"Upload link saved to {link_file_path}")
                    except Exception as e:
                        print(f"Failed to save the upload link: {e}")
                else:
                    print("Retrieved download link is invalid.")
            else:
                print("No download link found to save.")
    
    # Attach Functions to Buttons
    refresh_button.on_click(update_zip_files)
    start_upload_button.on_click(start_upload)
    
    # Arrange Widgets in the UI
    ui = VBox([
        widgets.HTML('<h2>dupload.net File Upload Automation Tool</h2>'),
        HBox([refresh_button]),
        widgets.Label('Select a Zip File to Upload:'),
        input_zip_widget,
        widgets.Label('Or Enter the File Path Below:'),
        file_path_widget,
        widgets.HTML('<h3>Credentials</h3>'),
        HBox([username_widget, password_widget]),
        widgets.Label('Directory to Save Upload Links:'),
        output_dir_widget,
        start_upload_button,
        widgets.HTML('<hr>'),
        output
    ])
    
    # Display the User Interface
    display(ui)
    
    # Initial Population of Zip Files List
    update_zip_files(None)