我有一个脚本可以从一个站点下载所有的.csv文件。它是工作正常,但我还需要得到一个列表与网址.csv文件。 下载的代码部分如下:
# Download files according to Xpath in table
def downloadfiles(Xpath):
global browser
time.sleep(10);
# Click csv img
try:
browser.find_element_by_xpath(Xpath).click()
global downloadcount
downloadcount = downloadcount + 1
return
# Element not found
except NoSuchElementException as e:
print("Error enxontró csv")
return
在这里我想我需要做些什么:browser.find_element_by_xpath(Xpath).click()
而不是点击我想得到链接。
代码是用python3.6和selenium编写的。
Xpath是"//*[@id=\"ctl00_ContentPlaceHolder1_ListViewNodos_ctrl0_ListViewArchivosSIN_ctrl0_linkCSV\"]"
如何获取.csv文件的链接列表?在
您可以使用
get_attribute("href")
获取链接 使用下面的代码行相关问题 更多 >
编程相关推荐