Skip to content

Commit c45a6bc

Browse files
committed
hotfix heatmap
1 parent 5affa55 commit c45a6bc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

folioflex/portfolio/wrappers.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from datetime import datetime, time, timedelta
1111
from io import StringIO
1212
from typing import Any, Dict, List, Optional, Union
13-
from urllib import request
1413
from urllib.parse import urlencode
1514

1615
import fredapi
@@ -309,14 +308,12 @@ def get_sp500_tickers(self) -> pd.DataFrame:
309308
310309
"""
311310
url = r"https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
312-
headers = {
313-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
314-
}
315-
req = request.Request(url, headers=headers)
316-
with request.urlopen(req) as response:
317-
html = response.read()
311+
request = requests.get(url, headers=_get_header(), timeout=10)
312+
request.raise_for_status()
318313

319-
sp500_tickers = pd.read_html(html)[0][["Symbol", "GICS Sector"]]
314+
sp500_tickers = pd.read_html(StringIO(request.text))[0][
315+
["Symbol", "GICS Sector"]
316+
]
320317

321318
sp500_tickers = sp500_tickers.rename(
322319
columns={

0 commit comments

Comments
 (0)