diff --git a/finviz/screener.py b/finviz/screener.py index 210137e..f757ec3 100644 --- a/finviz/screener.py +++ b/finviz/screener.py @@ -412,10 +412,14 @@ def __check_rows(self): def __get_table_headers(self): """ Private function used to return table headers. """ - - return self._page_content.cssselect('tr[valign="middle"]')[0].xpath( - "td//text()" - ) + + # Original line to get headers + raw_headers = self._page_content.cssselect('tr[valign="middle"]')[0].xpath("td//text()") + + # Clean headers by removing unwanted elements + clean_headers = [header.strip() for header in raw_headers if header.strip()] + + return clean_headers def __search_screener(self): """ Private function used to return data from the FinViz screener. """