Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
c4road committed Aug 14, 2023
1 parent 2d412a5 commit ed4286f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions finviz/helper_functions/scraper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ 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_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

options=[('class="count-text whitespace-nowrap">#1 / ',' Total</div>'),('class="count-text">#1 / ',' Total</td>')]
page_text = str(html.tostring(page_content))
for option_beg,option_end in options:
if option_beg in page_text:
total_number = page_text.split(option_beg)[1].split(option_end)[0]
try:
return int(total_number)
except ValueError:
return 0
return 0


def get_page_urls(page_content, rows, url):
Expand Down

0 comments on commit ed4286f

Please sign in to comment.