【发布时间】:2018-04-22 23:49:02
【问题描述】:
我想获得从 dictionary.cambridge.org 下载 mp3 文件的链接。 xpath 已找到正确的按钮,但在任何情况下我都无法获得链接。我试图使用 .text 和 .get_attribute("href") 方法。你有什么主意吗 ?
from selenium import webdriver
words=['hunch']
link='https://dictionary.cambridge.org/dictionary/english-polish'
driver = webdriver.Chrome()
main_window = driver.current_window_handle
for i in words:
driver.get(link+"/"+str(i))
try:
content = driver.find_elements_by_xpath('//*[@id="entryContent"]/div[3]/div/div/div[1]/span/span[2]/span[1]/span[2]')
print(content)
# print(content.text)
except:
driver.close()
driver.close()
【问题讨论】:
标签: python selenium selenium-webdriver web-scraping selenium-chromedriver