mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-16 06:11:57 +00:00
fix get_df for output in stocks/disc (#2667)
* Update disc_helpers.py * fixed linters * removed whitespace * reordered imports
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import re
|
||||
import pandas as pd
|
||||
import requests
|
||||
|
||||
|
||||
from openbb_terminal.helper_funcs import get_user_agent
|
||||
|
||||
|
||||
def get_df(url: str, header: int = None) -> pd.DataFrame:
|
||||
headers = {"User-Agent": get_user_agent()}
|
||||
html = requests.get(url, headers=headers).text
|
||||
dfs = pd.read_html(html, header=header)
|
||||
# use regex to replace radio button html entries
|
||||
html_clean = re.sub(r"(<span class=\"Fz\(0\)\">).*?(</span>)", "", html)
|
||||
dfs = pd.read_html(html_clean, header=header)
|
||||
return dfs
|
||||
|
||||
Reference in New Issue
Block a user