From f3a90d48032f0b4627d1671bb732678e49c44413 Mon Sep 17 00:00:00 2001 From: Siddharth Mathur Date: Mon, 2 Oct 2023 14:51:13 -0700 Subject: [PATCH] Replace instances of 'td' with 'th' --- finviz/screener.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/finviz/screener.py b/finviz/screener.py index 210137e..9a039fb 100644 --- a/finviz/screener.py +++ b/finviz/screener.py @@ -250,9 +250,9 @@ def load_filter_dict(reload=True): # Use one of the text values and get the parent table from that bs = BeautifulSoup(html, "html.parser") filters_table = None - for td in bs.find_all("td"): - if td.get_text().strip() == "Exchange": - filters_table = td.find_parent("table") + for th in bs.find_all("th"): + if th.get_text().strip() == "Exchange": + filters_table = th.find_parent("table") if filters_table is None: raise Exception("Could not locate filter parameters") @@ -262,18 +262,18 @@ def load_filter_dict(reload=True): # Populate dict with filtering options and corresponding filter tags filter_dict = {} - td_list = filters_table.find_all("td") + th_list = filters_table.find_all("th") - for i in range(0, len(td_list) - 2, 2): + for i in range(0, len(th_list) - 2, 2): current_dict = {} - if td_list[i].get_text().strip() == "": + if th_list[i].get_text().strip() == "": continue - # Even td elements contain filter name (as shown on web page) - filter_text = td_list[i].get_text().strip() + # Even th elements contain filter name (as shown on web page) + filter_text = th_list[i].get_text().strip() - # Odd td elements contain the filter tag and options - selections = td_list[i + 1].find("select") + # Odd th elements contain the filter tag and options + selections = th_list[i + 1].find("select") filter_name = selections.get("data-filter").strip() # Store filter options for current filter @@ -414,7 +414,7 @@ def __get_table_headers(self): """ Private function used to return table headers. """ return self._page_content.cssselect('tr[valign="middle"]')[0].xpath( - "td//text()" + "th//text()" ) def __search_screener(self):