mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Etf bug headers (#662)
* Ignore nft of the day test * Add user agent to etf requests
This commit is contained in:
@@ -18,7 +18,9 @@ def get_all_names_symbols() -> Tuple[List[str], List[str]]:
|
||||
etf_names: List[str]
|
||||
List of all available etf names
|
||||
"""
|
||||
r = requests.get("https://api.stockanalysis.com/etf/")
|
||||
r = requests.get(
|
||||
"https://api.stockanalysis.com/etf/", headers={"User-Agent": "Mozilla/5.0"}
|
||||
)
|
||||
soup = bs(r.text, "html.parser").findAll("ul", {"class": "no-spacing"})
|
||||
all_links = soup[0].findAll("li")
|
||||
etf_symbols = []
|
||||
@@ -43,7 +45,10 @@ def get_etf_overview(etf_symbol: str) -> pd.DataFrame:
|
||||
df : pd.DataFrame
|
||||
Dataframe of stock overview data
|
||||
"""
|
||||
r = requests.get(f"https://stockanalysis.com/etf/{etf_symbol}")
|
||||
r = requests.get(
|
||||
f"https://stockanalysis.com/etf/{etf_symbol}",
|
||||
headers={"User-Agent": "Mozilla/5.0"},
|
||||
)
|
||||
soup = bs(r.text, "html.parser") # %%
|
||||
tables = soup.findAll("table")
|
||||
texts = []
|
||||
@@ -75,7 +80,7 @@ def get_etf_holdings(symbol: str) -> pd.DataFrame:
|
||||
"""
|
||||
|
||||
link = f"https://api.stockanalysis.com/etf/{symbol}/holdings/"
|
||||
r = requests.get(link)
|
||||
r = requests.get(link, headers={"User-Agent": "Mozilla/5.0"})
|
||||
soup = bs(r.text, "html.parser")
|
||||
soup = soup.find("table")
|
||||
tds = soup.findAll("td")
|
||||
|
||||
@@ -291,7 +291,7 @@ class TestCoinGeckoAPI(TestCase):
|
||||
capt = capturedOutput.getvalue()
|
||||
self.assertIn("name", capt)
|
||||
|
||||
# TODO: Fix this test
|
||||
# TODO: fix this test
|
||||
# def test_coin_nft_of_the_day(self):
|
||||
# capturedOutput = io.StringIO()
|
||||
# sys.stdout = capturedOutput
|
||||
|
||||
Reference in New Issue
Block a user