通过硒单击链接

编程入门 行业动态 更新时间:2024-10-27 16:24:44
本文介绍了通过硒单击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试通过 Selenium 进行一些网页抓取.我的问题很简单:你如何找到一个链接,然后你如何点击它?例如:以下是我尝试抓取的 HTML:

I am trying to do some webscraping via Selenium. My question is very simple: How do you find a link and then how do you click on it? For instance: The following is the HTML that I am trying to web-scrape:

<td bgcolor="#E7EFF9"> <a href="javascript:selectDodasaDetdasdasy(220011643,'Kdasdası');" target="_self"> Details </a> </td>

因此,如您所见,详细信息"一词是一个链接.

So, as you can see the word "Details" is a link.

如何使用 Selenium 找到该链接并单击它?

How can I find that link using Selenium and click on it?

推荐答案

您可以使用 find_element_by_link_text:

You can use find_element_by_link_text:

例如:

link = driver.find_element_by_link_text('Details')

要点击它,只需调用 click 方法:

To Click on it, just call click method:

link.click()

更多推荐

通过硒单击链接

本文发布于:2023-11-27 20:41:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639525.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   链接

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!