#click the Strategy tester tab so that the button is visible
c = driver.find_element_by_xpath('//*[@id="footer-chart-panel"]/div[1]/div[1]/div[4]/div/span')
driver.execute_script("$(arguments[0]).click();", c)
#click the Export button
z = driver.find_element_by_xpath('//li[@class="autoview-backtesting-export"]')
driver.execute_script("$(arguments[0]).click();", z)
如果其中任何一项失败,请尝试添加一个循环(0-5),并将操作放入循环中。其余的都与熊猫有关
#copy the clipboard into dataframe
a = pd.read_clipboard(sep='\t', usecols=[])
如果你想缩短很短的时间(1s,5s),以防有人对此感兴趣。上述方法会产生问题,因为网站每10秒更新一次。我发现的方式如下所述:
下面是代码示例:
如果其中任何一项失败,请尝试添加一个循环(0-5),并将操作放入循环中。其余的都与熊猫有关
因此,启动器代码如下所示:
第一步是创建一个
webdriver
对象使用URL启动浏览器
此
driver
元素包含可用于从html获取元素的方法。 使用driver.page_source
可以获得完整的页面源代码。如果需要,只需使用soup = BeautifulSoup(driver.page_source, "html.parser")
即可切换到BeautifulSoup
可以对
driver
对象使用的一些方法有:这个link解释了如何使用
driver
对象在浏览器上模拟滚动来获取表数据最后,
您需要将chromedriver放置在
'/path/to/chrome_driver'
才能让selenium正常工作相关问题 更多 >
编程相关推荐