python - 如何使用selenium python查找网页中的链接总数

标签 python python-3.x

我已经在 J​​ava 中尝试过

int elementsCount = allElements.size(); 

.size()在Java中使用

Python中有没有其他选项,而不是使用FORLOOP。

最佳答案

您应该使用 find_elements_by_tag_name 这将为您提供带有 a 标记的所有元素的列表。

如果您使用find_element_by_tag_name,您只会得到第一个。

像这样:

total = driver.find_elements_by_tag_name("a") 
print(len(total))

希望这对您有帮助!

关于python - 如何使用selenium python查找网页中的链接总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52872330/

相关文章:

python - Fisher Yates Shuffle 错误实现中的顺序偏差

Python JSON 到 MYSQL - 动态

python - 如何推迟/推迟 f 弦的评估?

python - 使用带有 IN 语句的 cx_Oracle (Python 3)

Python - TypeError : tuple indices must be integers or slices, 不是 str

python - Keras 中损失函数的导数

python - 这个操作怎么称呼?

python - Ruby/Python 中是否有 OpenSource BASIC 解释器?

python - 如何在Python中使用PySnmp获取OID的值

python - 如何在 python 中创建一个运算符函数?