python - 我正在尝试使用提到的代码找到可点击/不可点击的墨水并在控制台中打印它
问题描述
此代码正在从给定的 URL 中提取链接。想要从提取的链接中划出可点击和不可点击的链接。
from selenium import webdriver
import time
ccount=0
ncount=0
URL = input('Enter URL: ')
driver = webdriver.Chrome()
URL = input('Enter URL: ')
driver.get(URL)
time.sleep(2)
ids = driver.find_elements_by_xpath('//*[@href]')
for a in ids:
print(a.get_attribute('href'))
解决方案
Selenium 中没有特定/预定义的可点击链接方法,我们必须执行点击操作并验证任何 UI 元素/元素属性
循环 clickableCount 数组
1. Save the current web url
2. Click on the link
3. Check whether URL changed or not and continue until end
推荐阅读
- php - 由于未捕获的 TypeError,如何创建空数组:无法读取 null 的属性“长度”
- html - 有没有办法让 flexbox 适合屏幕?
- rcpp - 我在 R 包中使用 Rcpp 和降雪的函数比不在包中的要慢
- java - 在 Windows 上从 Internet 访问 Jenkins
- javascript - 错误:SecurityError:URL 中的字符无效:
- java - get() 和 addListenerForSingleValueEvent 有什么区别?
- php - 在 PHP 渐进式 Web 应用程序上未检测到清单
- azure - 用于旧 Java SDK 的容器上的 Azure WORM/不可变保留锁定
- firefox - 如何在 Firefox 调试中找到丢失的图像
- reactjs - 如何使用 React 表单输入事件处理程序?