![](/img/trans.png)
[英]Python Selenium Web Automation How Do You Click A Login Button
[英]Python Selenium - How do you click on every row element for column of web table?
这可能是一个分为两部分的问题,如果编写得不好,请原谅我:
我正在尝试让我的WebDriver转到nba团队统计信息页面: http : //stats.nba.com/teams/traditional/#!? sort=W_PCT&dir=-1
然后单击表中链接的FGM编号。 这应该在后台打开一个新选项卡。 到目前为止,我已经完全迷失了应该如何实现这一目标。
我在想:
我确定可以使用BeautifulSoup获取数据,但我正在尝试使用Selenium并使用长度可能有所变化的表/链接。 任何线索表示赞赏。 谢谢!
Python示例:
from selenium import webdriver
from selenium.webdriver import ActionChains
web_driver = webdriver.Firefox()
web_driver.get("http://stats.nba.com/teams/traditional/#!?sort=W_PCT&dir=-1")
actions = ActionChains(driver)
team_links = webdriver.find_elements_by_xpath("//body//td[contains(@class, 'first')]/a")
for link in team_links:
actions.key_down(Keys.CONTROL).click(link).key_up(Keys.CONTROL).perform()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.