0

I new to python and selenium in general and i was trying to do a project based on it. code example:

options = Options()
options.headless = True
service_ = Service(executable_path = 'C:/Users/Downloads/chromedriver_win32/chromedriver.exe')
driver = webdriver.Chrome(service = service_, options = options)
wait = WebDriverWait(driver, 30)
driver.get(url_2)
manga_1 = driver.find_elements(By.XPATH, "//div[@class = 'item-summary']")
manga_1 = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class = 'item-summary']")))

When I was trying to run the code it gave me a error:

 raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 
Stacktrace:
Backtrace:
    Ordinal0 [0x00ABACD3+2075859]
    Ordinal0 [0x00A4EE61+1633889]
    Ordinal0 [0x0094B7BD+571325]
    Ordinal0 [0x0097AC2F+764975]
    Ordinal0 [0x0097AE1B+765467]
    Ordinal0 [0x009AD0F2+970994]
    Ordinal0 [0x00997364+881508]
    Ordinal0 [0x009AB56A+963946]
    Ordinal0 [0x00997136+880950]
    Ordinal0 [0x0096FEFD+720637]
    Ordinal0 [0x00970F3F+724799]
    GetHandleVerifier [0x00D6EED2+2769538]
    GetHandleVerifier [0x00D60D95+2711877]
    GetHandleVerifier [0x00B4A03A+521194]
    GetHandleVerifier [0x00B48DA0+516432]
    Ordinal0 [0x00A5682C+1665068]
    Ordinal0 [0x00A5B128+1683752]
    Ordinal0 [0x00A5B215+1683989]
    Ordinal0 [0x00A66484+1729668]
    BaseThreadInitThunk [0x76497BA9+25]
    RtlInitializeExceptionChain [0x778EBB9B+107]
    RtlClearBits [0x778EBB1F+191]


Process finished with exit code 1

I have tried fixing it by looking at youtube, but I am stuck and don't know what could it be.

1 Answers1

0

In the webpage there are numerous item summaries.

To extract the texts from the item summaries you have to induce WebDriverWait for visibility_of_all_elements_located() and using List Comprehension you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    driver.get("https://1stkissmanga.io/")
    print([my_elem.text for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.item-summary")))])
    driver.quit()
    
  • Using XPATH:

    driver.get("https://1stkissmanga.io/")
    print([my_elem.text for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='item-summary']")))])
    driver.quit()
    
  • Console Output:

    ['Martial Peak\n3.2\nChapter 2829\nChapter 2828', 'Tyrant Daddy’s Petite Bag\n5\nChapter 39\nChapter 38', 'If I Die, I will Be Invincible\n4.3\nChapter 39\nChapter 38', 'Be Jealous\n4\nChapter 24\nChapter 23', 'Deal With A Bad Boy\n5\nChapter 23\nChapter 22', 'I’m a Villainess But I Became a Mother\n4.1\nChapter 25.5\nChapter 25', 'Sunset Boulevard\n4\nChapter 20\nChapter 19', 'Elena Evoy Observation Diary\n4.5\nChapter 67\nChapter 66', 'Her Peculiar Visitor\n4.5\nChapter 59\nChapter 58 November 25, 2022', 'The Ex\n4.1\nChapter 117\nChapter 116', 'Love Hug\n3.5\nChapter 49\nChapter 48', 'Liar\n3.4\nChapter 43\nChapter 42', 'Usami’s Little Secret!\n4\nChapter 24\nChapter 23', 'Revenge Against the Immoral\n3.4\nChapter 60\nChapter 59', 'The Wounded Devil\n2.8\nChapter 23\nChapter 22', 'The Double Life of a Daydreaming Actress\n3.3\nChapter 62\nChapter 61', 'HOT\nDestined to be Empress\n3.7\nChapter 80\nChapter 79', 'The Widowed Empress Needs Her Romance\n4.4\nChapter 58\nChapter 57', 'Brother Mode\n3.6\nChapter 75\nChapter 74', 'Super Gene\n3.8\nChapter 83\nChapter 82']
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352