如何在python中使用selenium将表废弃到pandas数据帧中?

2024-09-29 23:19:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我想复制表(id=symbolMarket)并将其保存为pandas dataframe,保存在这个链接https://www.myfxbook.com/en/forex-market/currencies/US30-historical-data

请问我应该怎样用简单/漂亮的方式来做?在

显然,我可以逐个检索元素,但我相信有更好的方法。在

(如果有帮助,我使用selenium访问页面)

非常感谢与我分享知识


Tags: httpscomiddataframepandas链接wwwmarket
1条回答
网友
1楼 · 发布于 2024-09-29 23:19:40

我很犹豫是否要发表这篇文章,因为它非常基础,而且有很多解决方案展示了如何将html表读入pandas数据帧。让我想知道你是不是想先查一下。在

但是,只要使用.read_html()。这将返回一个数据帧列表。因此,您只需找出您想要的列表中的哪个数据帧:

import pandas as pd

url = 'https://www.myfxbook.com/en/forex-market/currencies/US30-historical-data'
tables = pd.read_html(url)

输出:

^{pr2}$

相关问题 更多 >

    热门问题