Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace instances of 'td' with 'th' #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions finviz/screener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down