{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "56264226",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: selenium in c:\\users\\magda\\anaconda3\\lib\\site-packages (4.30.0)\n",
      "Requirement already satisfied: urllib3<3,>=1.26 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (2.0.7)\n",
      "Requirement already satisfied: trio~=0.17 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (0.25.1)\n",
      "Requirement already satisfied: trio-websocket~=0.9 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (0.11.1)\n",
      "Requirement already satisfied: certifi>=2021.10.8 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (2024.2.2)\n",
      "Requirement already satisfied: typing_extensions~=4.9 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (4.9.0)\n",
      "Requirement already satisfied: websocket-client~=1.8 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (1.8.0)\n",
      "Requirement already satisfied: attrs>=23.2.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (23.2.0)\n",
      "Requirement already satisfied: sortedcontainers in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (2.4.0)\n",
      "Requirement already satisfied: idna in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (3.4)\n",
      "Requirement already satisfied: outcome in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (1.3.0.post0)\n",
      "Requirement already satisfied: sniffio>=1.3.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (1.3.0)\n",
      "Requirement already satisfied: cffi>=1.14 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.17->selenium) (1.16.0)\n",
      "Requirement already satisfied: wsproto>=0.14 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio-websocket~=0.9->selenium) (1.2.0)\n",
      "Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from urllib3[socks]<3,>=1.26->selenium) (1.7.1)\n",
      "Requirement already satisfied: pycparser in c:\\users\\magda\\anaconda3\\lib\\site-packages (from cffi>=1.14->trio~=0.17->selenium) (2.21)\n",
      "Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.14.0)\n"
     ]
    }
   ],
   "source": [
    "!pip install selenium\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "df2914a8",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: selenium in c:\\users\\magda\\anaconda3\\lib\\site-packages (4.30.0)\n",
      "Collecting selenium\n",
      "  Downloading selenium-4.33.0-py3-none-any.whl.metadata (7.5 kB)\n",
      "Collecting urllib3~=2.4.0 (from urllib3[socks]~=2.4.0->selenium)\n",
      "  Downloading urllib3-2.4.0-py3-none-any.whl.metadata (6.5 kB)\n",
      "Collecting trio~=0.30.0 (from selenium)\n",
      "  Downloading trio-0.30.0-py3-none-any.whl.metadata (8.5 kB)\n",
      "Collecting trio-websocket~=0.12.2 (from selenium)\n",
      "  Downloading trio_websocket-0.12.2-py3-none-any.whl.metadata (5.1 kB)\n",
      "Collecting certifi>=2025.4.26 (from selenium)\n",
      "  Downloading certifi-2025.4.26-py3-none-any.whl.metadata (2.5 kB)\n",
      "Collecting typing_extensions~=4.13.2 (from selenium)\n",
      "  Downloading typing_extensions-4.13.2-py3-none-any.whl.metadata (3.0 kB)\n",
      "Requirement already satisfied: websocket-client~=1.8.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from selenium) (1.8.0)\n",
      "Requirement already satisfied: attrs>=23.2.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (23.2.0)\n",
      "Requirement already satisfied: sortedcontainers in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (2.4.0)\n",
      "Requirement already satisfied: idna in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (3.4)\n",
      "Requirement already satisfied: outcome in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (1.3.0.post0)\n",
      "Requirement already satisfied: sniffio>=1.3.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (1.3.0)\n",
      "Requirement already satisfied: cffi>=1.14 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio~=0.30.0->selenium) (1.16.0)\n",
      "Requirement already satisfied: wsproto>=0.14 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from trio-websocket~=0.12.2->selenium) (1.2.0)\n",
      "Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from urllib3[socks]~=2.4.0->selenium) (1.7.1)\n",
      "Requirement already satisfied: pycparser in c:\\users\\magda\\anaconda3\\lib\\site-packages (from cffi>=1.14->trio~=0.30.0->selenium) (2.21)\n",
      "Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\magda\\anaconda3\\lib\\site-packages (from wsproto>=0.14->trio-websocket~=0.12.2->selenium) (0.14.0)\n",
      "Downloading selenium-4.33.0-py3-none-any.whl (9.4 MB)\n",
      "   ---------------------------------------- 0.0/9.4 MB ? eta -:--:--\n",
      "   ---------------------------------------- 0.1/9.4 MB 3.3 MB/s eta 0:00:03\n",
      "   - -------------------------------------- 0.3/9.4 MB 4.2 MB/s eta 0:00:03\n",
      "   -- ------------------------------------- 0.6/9.4 MB 4.5 MB/s eta 0:00:02\n",
      "   --- ------------------------------------ 0.9/9.4 MB 4.9 MB/s eta 0:00:02\n",
      "   ----- ---------------------------------- 1.2/9.4 MB 5.9 MB/s eta 0:00:02\n",
      "   ------ --------------------------------- 1.5/9.4 MB 5.3 MB/s eta 0:00:02\n",
      "   ------- -------------------------------- 1.9/9.4 MB 6.0 MB/s eta 0:00:02\n",
      "   --------- ------------------------------ 2.2/9.4 MB 6.1 MB/s eta 0:00:02\n",
      "   ----------- ---------------------------- 2.7/9.4 MB 6.5 MB/s eta 0:00:02\n",
      "   ------------ --------------------------- 2.9/9.4 MB 6.4 MB/s eta 0:00:01\n",
      "   ------------- -------------------------- 3.3/9.4 MB 6.5 MB/s eta 0:00:01\n",
      "   -------------- ------------------------- 3.5/9.4 MB 6.3 MB/s eta 0:00:01\n",
      "   --------------- ------------------------ 3.7/9.4 MB 6.1 MB/s eta 0:00:01\n",
      "   ----------------- ---------------------- 4.0/9.4 MB 6.1 MB/s eta 0:00:01\n",
      "   ------------------- -------------------- 4.5/9.4 MB 6.4 MB/s eta 0:00:01\n",
      "   --------------------- ------------------ 5.1/9.4 MB 7.0 MB/s eta 0:00:01\n",
      "   ------------------------ --------------- 5.7/9.4 MB 7.1 MB/s eta 0:00:01\n",
      "   -------------------------- ------------- 6.3/9.4 MB 7.4 MB/s eta 0:00:01\n",
      "   ---------------------------- ----------- 6.7/9.4 MB 7.5 MB/s eta 0:00:01\n",
      "   ------------------------------ --------- 7.2/9.4 MB 7.6 MB/s eta 0:00:01\n",
      "   -------------------------------- ------- 7.7/9.4 MB 7.8 MB/s eta 0:00:01\n",
      "   ---------------------------------- ----- 8.1/9.4 MB 7.8 MB/s eta 0:00:01\n",
      "   ------------------------------------- -- 8.7/9.4 MB 8.1 MB/s eta 0:00:01\n",
      "   ---------------------------------------  9.2/9.4 MB 8.1 MB/s eta 0:00:01\n",
      "   ---------------------------------------  9.4/9.4 MB 8.2 MB/s eta 0:00:01\n",
      "   ---------------------------------------  9.4/9.4 MB 8.2 MB/s eta 0:00:01\n",
      "   ---------------------------------------- 9.4/9.4 MB 7.6 MB/s eta 0:00:00\n",
      "Downloading certifi-2025.4.26-py3-none-any.whl (159 kB)\n",
      "   ---------------------------------------- 0.0/159.6 kB ? eta -:--:--\n",
      "   ---------------------------------------- 159.6/159.6 kB 4.7 MB/s eta 0:00:00\n",
      "Downloading trio-0.30.0-py3-none-any.whl (499 kB)\n",
      "   ---------------------------------------- 0.0/499.2 kB ? eta -:--:--\n",
      "   ------------------------------------ --- 450.6/499.2 kB 9.4 MB/s eta 0:00:01\n",
      "   ---------------------------------------- 499.2/499.2 kB 7.9 MB/s eta 0:00:00\n",
      "Downloading trio_websocket-0.12.2-py3-none-any.whl (21 kB)\n",
      "Downloading typing_extensions-4.13.2-py3-none-any.whl (45 kB)\n",
      "   ---------------------------------------- 0.0/45.8 kB ? eta -:--:--\n",
      "   ---------------------------------------- 45.8/45.8 kB ? eta 0:00:00\n",
      "Downloading urllib3-2.4.0-py3-none-any.whl (128 kB)\n",
      "   ---------------------------------------- 0.0/128.7 kB ? eta -:--:--\n",
      "   ---------------------------------------- 128.7/128.7 kB 3.8 MB/s eta 0:00:00\n",
      "Installing collected packages: urllib3, typing_extensions, certifi, trio, trio-websocket, selenium\n",
      "  Attempting uninstall: urllib3\n",
      "    Found existing installation: urllib3 2.0.7\n",
      "    Uninstalling urllib3-2.0.7:\n",
      "      Successfully uninstalled urllib3-2.0.7\n",
      "  Attempting uninstall: typing_extensions\n",
      "    Found existing installation: typing_extensions 4.9.0\n",
      "    Uninstalling typing_extensions-4.9.0:\n",
      "      Successfully uninstalled typing_extensions-4.9.0\n",
      "  Attempting uninstall: certifi\n",
      "    Found existing installation: certifi 2024.2.2\n",
      "    Uninstalling certifi-2024.2.2:\n",
      "      Successfully uninstalled certifi-2024.2.2\n",
      "  Attempting uninstall: trio\n",
      "    Found existing installation: trio 0.25.1\n",
      "    Uninstalling trio-0.25.1:\n",
      "      Successfully uninstalled trio-0.25.1\n",
      "  Attempting uninstall: trio-websocket\n",
      "    Found existing installation: trio-websocket 0.11.1\n",
      "    Uninstalling trio-websocket-0.11.1:\n",
      "      Successfully uninstalled trio-websocket-0.11.1\n",
      "  Attempting uninstall: selenium\n",
      "    Found existing installation: selenium 4.30.0\n",
      "    Uninstalling selenium-4.30.0:\n",
      "      Successfully uninstalled selenium-4.30.0\n",
      "Successfully installed certifi-2025.4.26 selenium-4.33.0 trio-0.30.0 trio-websocket-0.12.2 typing_extensions-4.13.2 urllib3-2.4.0\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
      "botocore 1.31.64 requires urllib3<2.1,>=1.25.4; python_version >= \"3.10\", but you have urllib3 2.4.0 which is incompatible.\n"
     ]
    }
   ],
   "source": [
    "pip install -U selenium\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c117b5cc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import time\n",
    "from datetime import datetime, timedelta\n",
    "from selenium import webdriver\n",
    "from selenium.webdriver.chrome.service import Service\n",
    "from selenium.webdriver.chrome.options import Options\n",
    "from selenium.webdriver.common.by import By\n",
    "from selenium.webdriver.support.ui import WebDriverWait\n",
    "from selenium.webdriver.support import expected_conditions as EC\n",
    "from selenium.common.exceptions import NoSuchElementException, TimeoutException"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "dc0bc03b",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "SessionNotCreatedException",
     "evalue": "Message: session not created: This version of ChromeDriver only supports Chrome version 137\nCurrent browser version is 136.0.7103.114 with binary path C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\nStacktrace:\n\tGetHandleVerifier [0x0x7ff7263c6f65+78965]\n\tGetHandleVerifier [0x0x7ff7263c6fc0+79056]\n\t(No symbol) [0x0x7ff726159dda]\n\t(No symbol) [0x0x7ff72619e0bf]\n\t(No symbol) [0x0x7ff72619d10b]\n\t(No symbol) [0x0x7ff726197a78]\n\t(No symbol) [0x0x7ff72619297d]\n\t(No symbol) [0x0x7ff7261e65be]\n\t(No symbol) [0x0x7ff7261e5d50]\n\t(No symbol) [0x0x7ff7261d8443]\n\t(No symbol) [0x0x7ff7261a1311]\n\t(No symbol) [0x0x7ff7261a20a3]\n\tGetHandleVerifier [0x0x7ff72667e26d+2926461]\n\tGetHandleVerifier [0x0x7ff726678993+2903715]\n\tGetHandleVerifier [0x0x7ff726696aed+3026941]\n\tGetHandleVerifier [0x0x7ff7263e16fe+187406]\n\tGetHandleVerifier [0x0x7ff7263e96ef+220159]\n\tGetHandleVerifier [0x0x7ff7263cfaf4+114692]\n\tGetHandleVerifier [0x0x7ff7263cfca9+115129]\n\tGetHandleVerifier [0x0x7ff7263b64d8+10728]\n\tBaseThreadInitThunk [0x0x7ffda8a3e8d7+23]\n\tRtlUserThreadStart [0x0x7ffda9f3c34c+44]\n",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mSessionNotCreatedException\u001b[0m                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[5], line 17\u001b[0m\n\u001b[0;32m     14\u001b[0m service \u001b[38;5;241m=\u001b[39m Service(chrome_driver_path)\n\u001b[0;32m     16\u001b[0m \u001b[38;5;66;03m# Initialize Chrome WebDriver with service and options\u001b[39;00m\n\u001b[1;32m---> 17\u001b[0m driver \u001b[38;5;241m=\u001b[39m webdriver\u001b[38;5;241m.\u001b[39mChrome(service\u001b[38;5;241m=\u001b[39mservice, options\u001b[38;5;241m=\u001b[39mchrome_options)\n\u001b[0;32m     19\u001b[0m \u001b[38;5;66;03m# Function to capture the snapshot\u001b[39;00m\n\u001b[0;32m     20\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcapture_snapshot\u001b[39m(date):\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py:47\u001b[0m, in \u001b[0;36mWebDriver.__init__\u001b[1;34m(self, options, service, keep_alive)\u001b[0m\n\u001b[0;32m     44\u001b[0m service \u001b[38;5;241m=\u001b[39m service \u001b[38;5;28;01mif\u001b[39;00m service \u001b[38;5;28;01melse\u001b[39;00m Service()\n\u001b[0;32m     45\u001b[0m options \u001b[38;5;241m=\u001b[39m options \u001b[38;5;28;01mif\u001b[39;00m options \u001b[38;5;28;01melse\u001b[39;00m Options()\n\u001b[1;32m---> 47\u001b[0m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__init__\u001b[39m(\n\u001b[0;32m     48\u001b[0m     browser_name\u001b[38;5;241m=\u001b[39mDesiredCapabilities\u001b[38;5;241m.\u001b[39mCHROME[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbrowserName\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[0;32m     49\u001b[0m     vendor_prefix\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgoog\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m     50\u001b[0m     options\u001b[38;5;241m=\u001b[39moptions,\n\u001b[0;32m     51\u001b[0m     service\u001b[38;5;241m=\u001b[39mservice,\n\u001b[0;32m     52\u001b[0m     keep_alive\u001b[38;5;241m=\u001b[39mkeep_alive,\n\u001b[0;32m     53\u001b[0m )\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\chromium\\webdriver.py:69\u001b[0m, in \u001b[0;36mChromiumDriver.__init__\u001b[1;34m(self, browser_name, vendor_prefix, options, service, keep_alive)\u001b[0m\n\u001b[0;32m     60\u001b[0m executor \u001b[38;5;241m=\u001b[39m ChromiumRemoteConnection(\n\u001b[0;32m     61\u001b[0m     remote_server_addr\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mservice\u001b[38;5;241m.\u001b[39mservice_url,\n\u001b[0;32m     62\u001b[0m     browser_name\u001b[38;5;241m=\u001b[39mbrowser_name,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     65\u001b[0m     ignore_proxy\u001b[38;5;241m=\u001b[39moptions\u001b[38;5;241m.\u001b[39m_ignore_local_proxy,\n\u001b[0;32m     66\u001b[0m )\n\u001b[0;32m     68\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 69\u001b[0m     \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__init__\u001b[39m(command_executor\u001b[38;5;241m=\u001b[39mexecutor, options\u001b[38;5;241m=\u001b[39moptions)\n\u001b[0;32m     70\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[0;32m     71\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mquit()\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py:257\u001b[0m, in \u001b[0;36mWebDriver.__init__\u001b[1;34m(self, command_executor, keep_alive, file_detector, options, locator_converter, web_element_cls, client_config)\u001b[0m\n\u001b[0;32m    255\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_authenticator_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m    256\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstart_client()\n\u001b[1;32m--> 257\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstart_session(capabilities)\n\u001b[0;32m    258\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_fedcm \u001b[38;5;241m=\u001b[39m FedCM(\u001b[38;5;28mself\u001b[39m)\n\u001b[0;32m    260\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_websocket_connection \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py:356\u001b[0m, in \u001b[0;36mWebDriver.start_session\u001b[1;34m(self, capabilities)\u001b[0m\n\u001b[0;32m    354\u001b[0m caps \u001b[38;5;241m=\u001b[39m _create_caps(capabilities)\n\u001b[0;32m    355\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 356\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexecute(Command\u001b[38;5;241m.\u001b[39mNEW_SESSION, caps)[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalue\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m    357\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession_id \u001b[38;5;241m=\u001b[39m response\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msessionId\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m    358\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcaps \u001b[38;5;241m=\u001b[39m response\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcapabilities\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py:447\u001b[0m, in \u001b[0;36mWebDriver.execute\u001b[1;34m(self, driver_command, params)\u001b[0m\n\u001b[0;32m    445\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcommand_executor\u001b[38;5;241m.\u001b[39mexecute(driver_command, params)\n\u001b[0;32m    446\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m response:\n\u001b[1;32m--> 447\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39merror_handler\u001b[38;5;241m.\u001b[39mcheck_response(response)\n\u001b[0;32m    448\u001b[0m     response[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalue\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_unwrap_value(response\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalue\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[0;32m    449\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m response\n",
      "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py:232\u001b[0m, in \u001b[0;36mErrorHandler.check_response\u001b[1;34m(self, response)\u001b[0m\n\u001b[0;32m    230\u001b[0m         alert_text \u001b[38;5;241m=\u001b[39m value[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124malert\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtext\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m    231\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m exception_class(message, screen, stacktrace, alert_text)  \u001b[38;5;66;03m# type: ignore[call-arg]  # mypy is not smart enough here\u001b[39;00m\n\u001b[1;32m--> 232\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exception_class(message, screen, stacktrace)\n",
      "\u001b[1;31mSessionNotCreatedException\u001b[0m: Message: session not created: This version of ChromeDriver only supports Chrome version 137\nCurrent browser version is 136.0.7103.114 with binary path C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\nStacktrace:\n\tGetHandleVerifier [0x0x7ff7263c6f65+78965]\n\tGetHandleVerifier [0x0x7ff7263c6fc0+79056]\n\t(No symbol) [0x0x7ff726159dda]\n\t(No symbol) [0x0x7ff72619e0bf]\n\t(No symbol) [0x0x7ff72619d10b]\n\t(No symbol) [0x0x7ff726197a78]\n\t(No symbol) [0x0x7ff72619297d]\n\t(No symbol) [0x0x7ff7261e65be]\n\t(No symbol) [0x0x7ff7261e5d50]\n\t(No symbol) [0x0x7ff7261d8443]\n\t(No symbol) [0x0x7ff7261a1311]\n\t(No symbol) [0x0x7ff7261a20a3]\n\tGetHandleVerifier [0x0x7ff72667e26d+2926461]\n\tGetHandleVerifier [0x0x7ff726678993+2903715]\n\tGetHandleVerifier [0x0x7ff726696aed+3026941]\n\tGetHandleVerifier [0x0x7ff7263e16fe+187406]\n\tGetHandleVerifier [0x0x7ff7263e96ef+220159]\n\tGetHandleVerifier [0x0x7ff7263cfaf4+114692]\n\tGetHandleVerifier [0x0x7ff7263cfca9+115129]\n\tGetHandleVerifier [0x0x7ff7263b64d8+10728]\n\tBaseThreadInitThunk [0x0x7ffda8a3e8d7+23]\n\tRtlUserThreadStart [0x0x7ffda9f3c34c+44]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Set the URL with initial parameters\n",
    "base_url = \"https://worldview.earthdata.nasa.gov/?v=-20.32694246665797,39.378487105812205,26.013324746342217,60.346251241902785&l=Reference_Labels_15m(hidden),Reference_Features_15m(hidden),Coastlines_15m,BlueMarble_NextGeneration(hidden),VIIRS_NOAA20_CorrectedReflectance_TrueColor(hidden),VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor&lg=true&s=4.7507,52.639&t={}\"\n",
    "\n",
    "# Set up the WebDriver\n",
    "chrome_driver_path = 'C:\\\\Users\\\\magda\\\\Master_Thesis\\\\chromedriver-win64\\\\chromedriver-win64\\\\chromedriver.exe'  # Replace with the path to your ChromeDriver\n",
    "\n",
    "\n",
    "\n",
    "# Set up Chrome options\n",
    "chrome_options = Options()\n",
    "chrome_options.add_argument(\"--headless\")  # Optional: run in headless mode\n",
    "\n",
    "# Initialize ChromeDriver service\n",
    "service = Service(chrome_driver_path)\n",
    "\n",
    "# Initialize Chrome WebDriver with service and options\n",
    "driver = webdriver.Chrome(service=service, options=chrome_options)\n",
    "\n",
    "# Function to capture the snapshot\n",
    "def capture_snapshot(date):\n",
    "    formatted_date = date.strftime(\"%Y-%m-%d-T%H:%M:%SZ\")\n",
    "    url = base_url.format(formatted_date)\n",
    "    driver.get(url)\n",
    "    time.sleep(5)  # Wait for the page to load fully\n",
    "    \n",
    "   \n",
    "    # Take a screenshot\n",
    "    try:\n",
    "        if not os.path.exists('snapshots'):\n",
    "            os.makedirs('snapshots')\n",
    "        driver.save_screenshot(f\"snapshots/snapshot_{formatted_date}.png\")\n",
    "        print(f\"Snapshot taken for {formatted_date}\")\n",
    "    except Exception as e:\n",
    "        print(f\"Error saving screenshot for {formatted_date}: {e}\")\n",
    "\n",
    "# Set the date range\n",
    "start_date = datetime(2024, 3, 20)\n",
    "end_date = datetime(2024, 3, 21)  # Example: capture snapshots for the month of March\n",
    "\n",
    "# Iterate over each day in the date range\n",
    "current_date = start_date\n",
    "while current_date <= end_date:\n",
    "    capture_snapshot(current_date)\n",
    "    current_date += timedelta(days=1)\n",
    "\n",
    "# Close the WebDriver\n",
    "driver.quit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7023a15e",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "print(os.getcwd())\n",
    "try:\n",
    "    os.makedirs('test_directory')\n",
    "    print(\"Directory created successfully.\")\n",
    "except OSError as error:\n",
    "    print(f\"Error creating directory: {error}\")\n",
    "try:\n",
    "    with open('test_file.txt', 'w') as f:\n",
    "        f.write('Testing file write permissions.')\n",
    "    print(\"File saved successfully.\")\n",
    "except IOError as error:\n",
    "    print(f\"Error saving file: {error}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
