【问题标题】:Python - Selenium: Find / Click YT-Like ButtonPython - Selenium:查找/单击类似 YT 的按钮
【发布时间】:2017-02-28 17:54:01
【问题描述】:

有没有人知道如何使用 selenium 在 Python 中查找/单击类似 YT 的按钮,因为它没有真正的 Id 等...

感谢您的回答

【问题讨论】:

  • 使用 CSS 选择器或 Xpath

标签: python selenium button youtube


【解决方案1】:

您可以像这样使用 CSS 选择器进行选择:

如果你想like:

#watch8-sentiment-actions > span > span:nth-child(1) > button

如果你想取消like:

#watch8-sentiment-actions > span > span:nth-child(2) > button

【讨论】:

  • Ouuuuu 伙计,你太棒了,我搜索了差不多一个小时的解决方案,但似乎我没有正确使用“find_by_css ...”。非常感谢:)
  • 你可以使用find_element_by_css_selector
  • 如果您使用的是 Chrome,您可以使用 Chrome 的检查器来查找元素的选择器或 xpath!
  • 是的,我当然做到了,而且效果很好,但我的意思是在你发布之前我没有正确使用它:)
猜你喜欢
  • 1970-01-01
  • 2021-04-10
  • 2020-04-14
  • 2021-03-18
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
  • 2015-09-01
  • 2020-07-28
相关资源
最近更新 更多