Skip to content

Commit

Permalink
[BUG] Fix get total columns in scrapper_functions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
c4road authored Jul 27, 2023
2 parents c977f8c + 5c49086 commit f683ee4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions finviz/helper_functions/scraper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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</td>')[0]
try:
return int(total_number)
except ValueError:
return 0


Expand Down

0 comments on commit f683ee4

Please sign in to comment.