Python无法从股票交易报告中获取表格
我的代码:
import time
import requests
import pandas as pd
from bs4 import BeautifulSoup
URL = "https://www.hkex.com.hk/eng/stat/dmstat/dayrpt/hsitmc220303.htm"
req = requests.get(URL)
page = BeautifulSoup(req.content, 'html.parser')
table = page.find_all('pre')
df = pd.read_html(str(table), displayed_only=False)[0]
print(df)
错误消息:
ValueError: No tables found
我想将表获取到数据帧。有什么建议吗?
My code:
import time
import requests
import pandas as pd
from bs4 import BeautifulSoup
URL = "https://www.hkex.com.hk/eng/stat/dmstat/dayrpt/hsitmc220303.htm"
req = requests.get(URL)
page = BeautifulSoup(req.content, 'html.parser')
table = page.find_all('pre')
df = pd.read_html(str(table), displayed_only=False)[0]
print(df)
Error message:
ValueError: No tables found
I want to get the table to dataframe. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效:
This should work :