我在Web应用程序中获取Web链接的数据。我使用Selenium模拟用户操作来验证经常访问的幻灯片,但是即使我手动执行幻灯片验证,也无法成功;如果我直接打开浏览器以访问链接,并执行滑动验证,则可以成功。有人可以告诉我为什么以及如何处理吗?
这是我的硒代码:
def driver(): Unit = {
System.setProperty("webdriver.chrome.driver", driverPath)
val options = new ChromeOptions()
options.addArguments("disable-extensions")
options.addArguments("disable-infobars")
val driver = new ChromeDriver(options)
val url="https://www.lazada.sg/products/xiaomi-mi-robot-vacuum-1-year-warranty-i100364584-s100369979.html"
try {
driver.get(url)
//if the page does not require verification, please request more than one or trigger it by other ways
//if the page needs to be verified, the following element will exist
val element = driver.findElementByCssSelector("#nocaptcha .nc-lang-cnt")
} catch {
case e: Exception => {
e.printStackTrace()
}
}
driver.close()
}