尝试点击源代码中说明此内容的链接
<a id="LeaderBoard1_cmdCSV" href="javascript:__doPostBack('LeaderBoard1$cmdCSV','')">Export Data</a></div>
我尝试通过id和链接文本进行定位,什么都没得到。任何帮助都会很棒。
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/tmp')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
browser = webdriver.Firefox(profile)
browser.get("http://www.fangraphs.com/leaders.aspx? pos=all&stats=bat&lg=all&qual=y&type=c,4,5,6,7,8,9,10,11,12,13,14,16,17,21,22,23,39,41,50&season=2015&month=1&season1=2002&ind=0&team=0&rost=1&age=0&filter=&players=0")
WebDriverWait(browser, 10)
browser.find_element_by_id("LeaderBoard1_cmdCSV").send_keys("\n")`
答案 0 :(得分:0)
假设您要模拟点击或&#34;输入密钥&#34;按下锚标记,最好使用.click()或.sendKeys(Keys.Enter)
from selenium.webdriver.common.keys import Keys