我对python和selenium都很陌生,我正试图基于它做一个项目。代码示例:
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']")))
当我试图运行代码时,它给了我一个错误:
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
我试着通过看youtube来修复它,但我被卡住了,不知道它会是什么。
1条答案
按热度按时间sg3maiej1#
在webpage中有许多项目摘要。
要从***项目摘要***中提取文本,您必须为visibility_of_all_elements_located()导出WebDriverWait,并使用List Comprehension,您可以使用以下locator strategies之一:
*注意:必须添加以下导入: