网站上有一个链接可下载csv文件。该链接位于表中,但实际的下载链接已隐藏。
<div id="testjs">
<div test-example="">
<table test-example="">
<tr test-example="">
<th test-example="">Car</th>
<th test-example="">File</th>
</tr>
<tr test-example="">
<td test-example="">Ford</td>
<td test-example="">
<a test-example="" href="#">ford.csv</a>
</td>
</tr>
</table>
</div>
</div>
我正在尝试通过使用python / selenium抓取网站来自动执行文件下载。
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get("https://www.example.com")
driver.find_element_by_link_text('ford.csv')
上面的最后一行运行时,脚本返回:
<selenium.webdriver.remote.webelement.WebElement (session="<example session string>",element="<example element string>")>
当我运行下面的代码时,没有任何反应:
driver.find_element_by_link_text('ford.csv').click()
我如何下载文件?