‘NoneType’ object is not subscriptable for Web Scrapping in Python

  Kiến thức lập trình

I have been trying to scrape the “Eyewear” products. However, i always get this errror for this category “‘NoneType’ object is not subscriptable”. I don’t know how to fix it. Please help or suggest any solutions.

Here is my code below:

# Navigating the Eye Wear subcategory products for women
try:
    menu_btn = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "//button[span[text()='MENU']]")))
    menu_btn.click()
except Exception as e:
        print(f"An error occurred while opening the main menu: {e}")

try:
    #Open the Men Category
    men=WebDriverWait(driver,10).until(
        EC.element_to_be_clickable((By.XPATH, "//button[@id='l1_navigation_item_5']")))
    men.click()
except Exception as e:
    print(f"Error occured while opening the Men Category:{e}")

try:
    accessories_men = WebDriverWait(driver,10).until(
        EC.element_to_be_clickable((By.XPATH, "//button[@id='l2_navigation_item_5_7']")))
    accessories_men.click()
except Exception as e:
    print(f"An error occured while opening the accessories for men subcatogory:{e}")
try:
    eyewear_men = WebDriverWait(driver,10).until(
        EC.element_to_be_clickable((By.XPATH,'//*[@id="menu-container-level-5-7-3"]/ul/li[3]/div/a')))
    eyewear_men.click()
except Exception as e:
    print(f"An error occured while opening the eyewear items for men:{e}")

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT