joenano / rpscrape

Scrape horse racing results data and racecards.
140 stars 57 forks source link

ValueError: invalid literal for int() with base 10: '' #111

Closed patem2 closed 2 years ago

patem2 commented 2 years ago

Hi,

When trying to pull the racecards this morning the following error is presented:

Traceback (most recent call last): File "racecards.py", line 440, in main() File "racecards.py", line 430, in main races = parse_races(session, race_urls, date) File "racecards.py", line 367, in parse_races runners[horse_id]['lbs'] = int(find(horse, 'span', 'RC-cardPage-runnerWgt-carried', attrib='data-order-wgt')) ValueError: invalid literal for int() with base 10: ''

Best wishes Mark

gbettle commented 2 years ago

Hi Mark,

If you feel up to it, Wrap line 367 in a try\except:

        try:
            runners[horse_id]['lbs'] = int(find(horse, 'span', 'RC-cardPage-runnerWgt-carried', attrib='data-order-wgt'))
        except:
            runners[horse_id]['lbs'] = None

Cheers,

G.

patem2 commented 2 years ago

Brilliant Gary, worked like a charm :-)

I'm learning my way around Python but still an absolute novice lol

I'm ok with Power Query M code / excel and DAX and I'm trying to expand my repertoire.

Thanks for the help.

Best Mark