diff --git a/finviz/screener.py b/finviz/screener.py index 210137e..3e53635 100644 --- a/finviz/screener.py +++ b/finviz/screener.py @@ -412,10 +412,18 @@ 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()" - ) + headers = [] + + header_elements = self._page_content.cssselect('tr[valign="middle"]')[0].xpath("td") + + for header_element in header_elements: + # Use normalize-space to extract text content while ignoring internal elements + header_text = header_element.xpath("normalize-space()") + + if header_text: + headers.append(header_text) + + return headers def __search_screener(self): """ Private function used to return data from the FinViz screener. """ diff --git a/pyproject.toml b/pyproject.toml index 592e72e..f88b6f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,4 +29,4 @@ dependencies =[ requires-python = ">=3.8" [tools.setuptools] -packages = ["finviz"]git \ No newline at end of file +packages = ["finviz"]