我已经用python和selenium编写了一个脚本来启动对网页中可用链接的点击。它们都与hperlinks非常相似。我要单击的链接是每个容器的名称,因为在第一个链接中,连接到这个名称的链接是Kimpton Muse Hotel
(名称可能因您的情况而异),以此类推。我已经检查了我的脚本是否可以解析这些名称,但不能单击连接到每个名称的链接。你知道吗
这是我迄今为止的尝试:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "replace with the link above"
driver = webdriver.Chrome()
driver.get(url)
wait = WebDriverWait(driver, 10)
for item in wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".VkpGBb .dbg0pd div"))):
# item.click() #it throws an error when uncommented
print(item.text) #this works great
driver.quit()
这是取消对行item.click()
的注释时出现的错误:
line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <div>...</div> is not clickable at point (106, 238). Other element would receive the click: <div jstcache="360" jsaction="cal_select_day:jsl._" class="gws-travel-calendar__calendar">...</div>
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86)
What I wish to do is click on those links cyclically and that's it.
下图显示了我希望单击的链接(用铅笔记号笔标记)
尝试在每次迭代时关闭详细信息模式弹出窗口:
有一个日历窗口打开,一旦我们访问搜索佩奇。你呢可以单击完成按钮并运行相同的代码:
以下是我的做法:
进口将是:
以下是控制台输出:
更新1:
包装完成按钮点击
try-catch
:相关问题 更多 >
编程相关推荐