我想从这个网站(https://www.otcmarkets.com/research/stock-screener)提取各种统计数据。不幸的是,熊猫不认识这些桌子。这是我的密码:
import requests
import pandas as pd
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36'}
def Get_table(screen):
tables = pd.read_html(screen)
tables.columns = tables.iloc[0]
return tables
screen = requests.get('https://www.otcmarkets.com/research/stock-screener', headers = header).text
table = Get_table(screen)
ValueError:未找到任何表
页面从外部源(URL)加载数据。您可以使用此示例了解如何从API加载数据并创建数据帧:
印刷品:
相关问题 更多 >
编程相关推荐