joenano / rpscrape

Scrape horse racing results data and racecards.
143 stars 59 forks source link

Problem downloading tomorrow's racecard (04-Nov-23) #137

Closed rmwesley99 closed 11 months ago

rmwesley99 commented 11 months ago

I'm guessing everyone is getting the same issue downloading the racecard for tomorrow?

(rp) rpscrape@raspberrypi:~/projects/rp/rpscrape/scripts $ python3 racecards.py tomorrow
Traceback (most recent call last):
  File "/home/rpscrape/projects/rp/rpscrape/scripts/racecards.py", line 473, in <module>
    main()
  File "/home/rpscrape/projects/rp/rpscrape/scripts/racecards.py", line 463, in main
    races = parse_races(session, race_urls, date)
  File "/home/rpscrape/projects/rp/rpscrape/scripts/racecards.py", line 357, in parse_races
    runners = get_runners(session, profile_urls)
  File "/home/rpscrape/projects/rp/rpscrape/scripts/racecards.py", line 149, in get_runners
    runner['age'] = int(js['profile']['age'].split('-')[0])
ValueError: invalid literal for int() with base 10: 'Died as a 3'

Bit pressed for time at the mo, so I'm assuming it is weird HTML on the website rather than an issue in the code. Will try downloading it again later. Cheers, Richard

hmesser1 commented 11 months ago

Getting the same issue too I'm afraid.

patem2 commented 11 months ago

Same for me guys :-)

patem2 commented 11 months ago

The offending horse is Practical-Move who was put forward for the 18:30 at Santa Anita USA, strange it's picking it up as it's obviously a non-runner?

rmwesley99 commented 11 months ago

Any ideas how to hack it to exclude this race or horse? I'd have a crack myself, but I'm away this weekend. If anyone does manage it, would you be able to share the JSON file? Many thanks!

patem2 commented 11 months ago

I’m also on holiday lol

I’ll have a go in a bit, I tried a try / except on line 149 which didn’t work but haven’t had a chance to look at it properly.

The course ID from memory was 257 so maybe try to exclude in the reference file by commenting it out (which will probably spawn more errors lol)

Caprice63 commented 11 months ago

I also have the same problem. However I only require the gb and ire races. Is there a simple way to filter these before the script starts to scrape the race cards?

patem2 commented 11 months ago

2023-11-04.json

Here you go guys, added another try / except statement as it generated a key error after the first try / except on the ValueError I'd tried earlier

joenano commented 11 months ago

Its fixed.

rmwesley99 commented 11 months ago

As always, many thanks @joenano for sorting it out.

Some day we all need to find a way to buy you a load of beers.

Also thanks @patem2 for the JSON.

hmesser1 commented 11 months ago

As always, many thanks @joenano for sorting it out.

Some day we all need to find a way to buy you a load of beers.

Also thanks @patem2 for the JSON.

Thanks to everyone. Really appreciated

patem2 commented 11 months ago

My pleasure guys and seconding the beers for joenano - way overdue 😀