本文介绍了通过硒单击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过 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()更多推荐
通过硒单击链接
发布评论