From 5c4908603c06d6f6786ee2644254014dec228234 Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 27 Jul 2023 11:19:52 -0300 Subject: [PATCH] init --- finviz/helper_functions/scraper_functions.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/finviz/helper_functions/scraper_functions.py b/finviz/helper_functions/scraper_functions.py index 573fa0a..afee99b 100644 --- a/finviz/helper_functions/scraper_functions.py +++ b/finviz/helper_functions/scraper_functions.py @@ -40,17 +40,10 @@ def get_table(page_html: requests.Response, headers, rows=None, **kwargs): def get_total_rows(page_content): """ Returns the total number of rows(results). """ - - total_element = page_content.cssselect('td[width="128"]') - if len(total_element) > 0: - content = etree.tostring(total_element[0]).decode("utf-8") - total_number = content.split("/")[1].split()[0] - - try: - return int(total_number) - except ValueError: - return 0 - else: + total_number = str(html.tostring(page_content)).split('class="count-text">#1 / ')[1].split(' Total')[0] + try: + return int(total_number) + except ValueError: return 0