Greyhound Mystique

Any markets not covered in the other boards
Post Reply
PeterLe
Posts: 3729
Joined: Wed Apr 15, 2009 3:19 pm

spreadbetting wrote:
Wed Jan 22, 2020 3:42 pm
Bog wrote:
Wed Jan 22, 2020 3:13 pm

How much time it took to learn that? I started to watch Python tutorials on YT, total newbie, never coded, but looks interesting. So much info. Any advice? :mrgreen:
Probably not as long as you'd think , I bought the £9 udemy python course that was recommended on this thread viewtopic.php?f=55&t=19959

It's about 30 hours but most of that is exercises or tests which I skipped as they were a bit boring plus some of the SQL stuff isn't needed to start but not hard either. I finished watching it around xmas time so needed to test my new found skills on something and scraping with python isn't too hard. I had coded previously with php but mainly just look on google when I need to do something still . But doing a course does give you that structured learning and the course, even though it gets boring, is quite good and well done. I probably managed around an hour most days, can't imagine I'd be able to write anything without google though :) But for me coding is a means to an end so once I have something working I never bother coding or trying to code.

Only had dealings so far with VBA for excel, php for old web stuff and python but got to say python is definetly the easiest and , being a newer language, seems to have learnt alot from the failings of other coding languages.

Here's the code I wrote, I imagine most pro coders would spot so many areas it could be made more efficient but as a first attempt at a scraper I was happy it actually kicked out what I needed.

Code: Select all

import re
import requests
from bs4 import BeautifulSoup
from requests_html import HTMLSession


def extract_times(input):
    times_regex = re.compile(r'Best: (.....)sLast: (.....)s')
    best_times_regex = re.compile(r'Best: (.....)s')
    match = times_regex.search(input)
    best_match = best_times_regex.search(input)
             
    if match:
        if float(match.group(2)) < float(match.group(1)):
            return float(match.group(1))
        else:        
            return round((float(match.group(1))+float(match.group(2)))/2,2)
            
    if best_match:
        return float(best_match.group(1))
    
    return 100

session = HTMLSession()
baseUrl = "https://www.sportinglife.com"
str="/greyhounds/racecards/20"

res = requests.get("https://www.sportinglife.com/greyhounds/racecards")
soup=BeautifulSoup(res.text,"html.parser")
summary=soup.find_all("a", class_="")

x=0
for link in soup.find_all('a'):
    link = link.get('href')
    
    if str in link:
        res = session.get(baseUrl+link)
        soup=BeautifulSoup(res.text,"html.parser")
        race = soup.find_all('h1')[1].get_text()
        distance =soup.find(class_='gh-racecard-summary-race-class gh-racecard-summary-always-open').get_text()
        summary=soup.find_all(class_="gh-racing-runner-key-info-container")
        Runners = dict()

        for link in summary:
            Trap= link.find(class_="gh-racing-runner-cloth").get_text()
            Name =re.sub(r'\(.*\)', '',link.find(class_="gh-racing-runner-greyhound-name").get_text())
            Average_time = extract_times(link.find(class_="gh-racing-runner-greyhound-sub-info").get_text())
            Runners[Average_time]= Trap+'. '+Name


        if bool(Runners) == True and ('OR' in distance or 'A' in distance):

            x = sorted(((k,v) for k,v in Runners.items()))

            if (x[1][0]-x[0][0]) >=0.1:
                
                timeDiff =round((x[1][0]-x[0][0]),2)
                print(f"{race},{x[0][1]}, class {distance}, time difference {timeDiff}")
                
SB Thanks for posting this code. Just run it and it looks good!
(For anyone new to Python, I had to :

PIP Install request
PIP Install requests_html

From terminal to get it running
Archery1969
Posts: 4478
Joined: Thu Oct 24, 2019 8:25 am

These are my BTL Trades for Mon Mar 09:
Perry Barr
11:03   A9   3   Commanche Rising
11:34   A8   6   Bellside Tic

Swindon
11:11   A5   3   Goeasyonme
11:56   A3   5   Westwell Delilah
12:26   A8   6   Skyflash Ralph
12:42   A6   6   Renegade Reason
12:57   A8   4   Magical Lesley

Henlow
13:39   A9   4   Ebony Velvet

Monmore
14:06   A2   1   Roxhill Mystique
16:58   A4   3   Manks Vanfrater
17:37   A5   6   Bow Lightening

Romford
15:49   A4   5   Cairns Hubble
17:08   A2   1   Moorstown Victor
17:44   A1   1   Secondtimearound

Sheffield
16:27   A6   2   Corgrigg Saoirse
16:46   A5   4   Swift Benedict
17:06   D2   2   Exiles Rocket
17:56   D3   2   Funk Leader
18:11   A8   4   Harper Of Hearts

Yarmouth
19:42   A4   2   Memories Star
20:13   A6   4   Suirview Mia
20:44   A8   6   Trapper Nellie
20:59   A5   5   Snowflake Girl
21:14   A5   4   Black Pepper

Nottingham
18:47   A3   1   Ashgrove Raven

Doncaster
19:03   B5   6   Ted Holdem
19:17   B3   1   Terrific Tina
20:06   B4   6   Tullyotter Queen
20:21   D3   3   Nans Primrose
21:08   B7   4   Hilltop Boozer

Harlow
20:11   A7   2   Lurriga Silver

These are my LTB Trades for Mon Mar 09:
Perry Barr
11:03   A9   6   Petite Honey
11:34   A8   5   Johns Vintage
12:48   A3   5   Catunda Robert
13:04   A7   5   Running Scholar

Swindon
11:11   A5   5   Wychwood Harvey
11:56   A3   4   Jet Stream News
13:12   A5   1   Brickfield Grace
13:27   A3   6   Sunfield Ruby

Central Park
12:01   A4   1   Hazelwoodjayfkay

Henlow
13:08   A4   5   Savana Alvez
13:39   A9   2   Domino Ninja

Monmore
15:02   A4   2   Strategic Stevie
16:58   A4   2   Southlodge Kane
17:54   A6   3   Kaybee Sapphire

Romford
14:52   A5   1   Jaxx Mermaid
15:11   A3   6   Borwick Bob
15:29   A2   1   Rough Hammer
17:08   A2   5   Slaneyside Otis

Sheffield
16:46   A5   1   Young Jayfkay
17:06   D2   5   Coney Ciroc
18:11   A8   1   Autumn Reaper

Yarmouth
18:22   A3   2   Milky Bar
20:44   A8   3   Clonard Pearl

Doncaster
20:06   B4   4   Barnside Lottie
21:08   B7   1   Luttons Meghan
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

PeterLe wrote:
Mon Mar 09, 2020 11:32 am

SB Thanks for posting this code. Just run it and it looks good!
(For anyone new to Python, I had to :

PIP Install request
PIP Install requests_html

From terminal to get it running
Glad you found it useful , Peter, it was basically cobbled from that course and checking stackoverflow.com whenever I was stuck or an error cropped up. I actually changed the script you quoted to include some error trapping and dump the data to a text file so it can be imported elsewhere . Screen scraping is always a nightmare as websites change things on their site on a whim and then errors you haven't accounted for start to crop up. So much easier to deal with API's where the format is stable.

Here's the current version with some try/except trapping, just needs the file address amending to whatever directory people want. Hopefully it'll be of use to someone as I remember when I started coding you need something that works so you can deconstruct it rather than printing "Hello" to the screen.

Code: Select all

myfile = open('C:\\Users\\?????????\\Desktop\\dogs.txt', 'w')

                   
greyhound.rar
poklius
Posts: 105
Joined: Sun May 17, 2009 11:58 am

spreadbetting wrote:
Mon Mar 09, 2020 12:36 pm
So much easier to deal with API's where the format is stable.
I suppose you are scraping sporting life? They do have API, its not public but quite easy to spot with some network monitoring.
sportinglife.com/api/greyhound-racing/race/193152 <- last digits are race ID from their front page. Scrap them from front page or just go from ID 1, for some 2016 data, lol.
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

Thanks, poklius, I'll check it out tomorrow see what data it returns.
User avatar
whimsies
Posts: 181
Joined: Sun Oct 02, 2016 7:37 am

Thank you spreadbetting for the code, and peterle pointing me in the right direction. The information was very generous of you.

Thanks again

Mark
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

poklius wrote:
Mon Mar 09, 2020 8:03 pm
spreadbetting wrote:
Mon Mar 09, 2020 12:36 pm
So much easier to deal with API's where the format is stable.
I suppose you are scraping sporting life? They do have API, its not public but quite easy to spot with some network monitoring.
sportinglife.com/api/greyhound-racing/race/193152 <- last digits are race ID from their front page. Scrap them from front page or just go from ID 1, for some 2016 data, lol.
Just had a quick look and looks like it's got everything you need and more :)

Big thanks for that , have to do a complete recode now to use all the available data, I'll see if I can find the football and racing api's too as they'll be very useful to scrape ;)

Any advice on a decent , and free, network monitor to use?
poklius
Posts: 105
Joined: Sun May 17, 2009 11:58 am

spreadbetting wrote:
Tue Mar 10, 2020 12:08 pm
Any advice on a decent , and free, network monitor to use?
I use "Inspect Element" tool in Firefox browser, at Network tab you can see everything that is being loaded. Look for json, xml data types. Most of the time if page is not pure javascript you can find links to some kind of text format data.
Emmson
Posts: 3577
Joined: Mon Feb 29, 2016 6:47 pm

Some bot must have misfired 18.11 Monmore all of the runners appear to have been matched at 40s for quite a few quid.
Archery1969
Posts: 4478
Joined: Thu Oct 24, 2019 8:25 am

These are my BTL Trades for Wed Mar 11:
Swindon
11:03   A9   2   Knockmehill Jim
11:34   A3   2   Geelo Dee Dee
11:48   A6   2   Saleen Mollie
12:04   A3   4   Crypto Blues
12:48   A9   2   Coolykereen Day
13:04   A9   1   Sirius Lady

Central Park
11:14   D3   6   Miss Van Dijk
11:28   A5   1   Heather Time
11:59   A2   1   Maireads Brave
13:28   A2   5   Holborn Runtowin

Romford
13:22   A4   4   Shake It Up
13:37   A9   3   Marbella Katie

Newcastle
13:59   A8   3   Sals Magic

Monmore
14:18   A6   4   Crackerjackie
15:18   A3   2   Rip Rock Paddy
17:18   A7   5   Up To You

Belle Vue
16:27   A6   4   Michaels Advice
17:56   A2   2   Shaneboy Berg

Hove
14:48   A7   5   Annies King
15:27   A9   2   Insane Rocky
16:07   A8   2   Conor Pass Flyer

Sunderland
18:39   A3   5   Zari Bally
18:55   A1   1   Abbys Attitude
20:13   HP   6   Fairholme Sky
20:44   A5   4   Mayhem Mollie

Doncaster
18:27   A2   5   Santro Mac
18:44   A2   1   Haven Dreamer
19:17   A4   5   A Definate Berry
19:33   A5   6   Sive The Lady
20:38   D3   6   Charlie Be Slick

Peterborough
20:37   A4   2   Breeze

These are my LTB Trades for Wed Mar 11:
Swindon
11:03   A9   1   Marley Boy
12:04   A3   1   Ballymac Wow
12:48   A9   4   Treanaree Lilly

Central Park
11:59   A2   4   Holborn Tilly
12:13   D2   5   Castlerock Jack
13:47   HP   1   Tiger Duke

Romford
12:36   A8   4   Beautiful South
13:22   A4   1   Bonville Bruno
13:37   A9   5   Harley Queen

Newcastle
13:44   HP   1   Watermill Elsa

Monmore
14:18   A6   6   Smokestack Loco
15:18   A3   4   Headleys Breda
17:18   A7   2   Moorstown Paddy

Belle Vue
14:27   A7   3   Croaghill Nancy
15:47   A6   5   Mrs Mac
16:27   A6   2   Belle Vue Ruth
16:46   A5   6   Burning Rubber
18:11   A4   5   Blistering Flash

Hove
14:48   A7   1   Snooze Ya Lose
17:28   A5   3   Rockys Ace

Sunderland
18:22   A4   3   Los Pepes
18:39   A3   4   Greenhall Stella
20:13   HP   2   Cappagh Tess
20:29   HP   2   Nuthill Jackie
20:44   A5   5   Mouna Gneiss
21:14   A2   4   Vincys Jaxxon

Doncaster
18:27   A2   6   Let It Ride
19:17   A4   2   Nolas Bloom
20:53   B4   5   Moss Keeto

Peterborough
19:05   A5   3   Maybeanothertime
20:37   A4   5   Beech Hill Jet
20:51   A7   4   Making Moments
Archery1969
Posts: 4478
Joined: Thu Oct 24, 2019 8:25 am

These are my BTL Trades for Thu Mar 12:
Sheffield
11:41   A7   4   Geelo Georgia

Henlow
12:21   A9   3   Silverview Sweep

Sunderland
12:33   A3   5   Seomra Keel

Perry Barr
14:08   A3   4   Final Elaine
15:07   A5   1   Youre Raving
16:07   HP   6   Drahbeg Delish
17:22   A6   1   Final Star
17:56   A7   2   Porthall Magic

Romford
14:28   A3   2   Tourbo Marmaduke
14:48   A6   4   Borwick Happy
15:27   A2   5   Slaneyside Nemo
16:28   A3   3   Ballyfinn Salah
17:47   A1   1   Johnsons Rose
18:19   A7   5   Borwick Turbo

Crayford
15:58   A8   5   Savana Timmy

Monmore
18:33   A2   4   Droopys Tui
20:27   A4   1   Final Wolf

Yarmouth
20:51   A3   4   Take My Advice

Newcastle
19:42   A3   4   Crooks Pablo

These are my LTB Trades for Thu Mar 12:
Sheffield
11:41   A7   1   Stunning Ivy
13:44   A7   3   Gatelodge Darcy

Henlow
12:21   A9   2   Greencroft Tiger
13:22   A7   1   Savana Eden
13:37   A6   2   Fieldview Andy

Sunderland
13:04   HP   2   Suncroft Katie

Central Park
13:47   A1   3   Monagea Cross

Perry Barr
14:08   A3   3   Autumn Dapper
15:07   A5   3   Whizzing Jenny
15:47   A8   4   Barnagrane Grace
16:07   HP   1   Ballymac Prize
17:22   A6   5   Newline Shane
17:56   A7   6   Rathmoyle Lisa

Romford
14:48   A6   1   Borwick Old Fort
15:27   A2   4   Ace High Jazz
17:47   A1   3   Piemans Tom

Hove
18:27   A5   2   Feora Tyson

Monmore
18:33   A2   5   Bloos Bon Jenks

Yarmouth
19:05   A7   3   Reality Train
19:19   A7   3   Denises Boy
21:22   A5   2   Ascot Kiki
towelfox
Posts: 32
Joined: Mon May 27, 2019 10:32 pm
Contact:

Thanks for this thread, it's given me some good ideas. I notice some of you are scraping for data. Me too!

I've got the last 6 year's race data (only ISP unfortunately, not got BSP) and full daily racecards from a mixture of sources. It's a work in progress at the moment but naturally I'll be able to pull out any kind of stats into a website (half built already) and a daily report. If anyone is interested in hearing more in a data for advice kind of way I'd be very interested in talking. Hope this is allowed in my first post.

I've attached a couple of screenshots of a sample racecard from a 2017 race. The performance matrix has many, many colums.

Cheers
You do not have the required permissions to view the files attached to this post.
User avatar
Crazyskier
Posts: 1303
Joined: Sat Feb 06, 2016 6:36 pm

Archery?

No selections for last 2 days?

I've become dependent on them for guidance, lol. I hope you'll post again soon - the selections are appreciated.

CS
User avatar
wearthefoxhat
Posts: 3593
Joined: Sun Feb 18, 2018 9:55 am

towelfox wrote:
Sat Mar 14, 2020 9:11 am
Thanks for this thread, it's given me some good ideas. I notice some of you are scraping for data. Me too!

I've got the last 6 year's race data (only ISP unfortunately, not got BSP) and full daily racecards from a mixture of sources. It's a work in progress at the moment but naturally I'll be able to pull out any kind of stats into a website (half built already) and a daily report. If anyone is interested in hearing more in a data for advice kind of way I'd be very interested in talking. Hope this is allowed in my first post.

I've attached a couple of screenshots of a sample racecard from a 2017 race. The performance matrix has many, many colums.

Cheers
The information is well presented/formatted.

Looking at the example, it would be fairly easy to create some sort of method for laying or backing.
Archery1969
Posts: 4478
Joined: Thu Oct 24, 2019 8:25 am

Very sorry for delays, had some issues with my email. :(

These are my BTL Trades for Sat Mar 14:
Romford
10:29   A9   3   Marbella Katie
11:12   A2   4   Im Alright Jack
11:27   A4   4   Waikiki Honey
11:59   A1   2   Bubbly Flair
12:28   A3   5   Thatchers Puma
13:14   A8   4   Milltown Katie
13:28   A2   6   Up Above
19:28   A7   4   Gosh Owen
19:44   A3   1   Chopchop Archie
19:59   A3   1   Waikiki Boy
21:03   A1   5   Droopys Firmino
22:15   A2   1   Phantom Bob

Crayford
11:06   A7   6   Goodwood Express
12:06   A8   5   Ballymac Rosino
12:36   A9   4   Sophies Eclipse
20:00   A1   2   Trade Joey
20:51   A5   3   Erins Solange

Newcastle
14:24   A6   5   Do The Floss
14:59   A7   4   Galley Jessie
16:28   A7   2   View Red
17:27   A7   3   Styamra Duke
17:44   A8   1   Feetinthesand
17:59   A6   4   Mill Giradi
20:04   A1   3   Honey Crystal
20:19   A5   1   Showmethebunny

Henlow
14:28   A5   3   Westmead Ago
14:48   A3   4   Silvus Blue Jay
15:07   A5   2   Savana Pat
18:03   A9   4   Up Donegal
18:18   A9   1   Brilliant Design

Doncaster
14:38   A2   5   Ballymac Mcgrath

Monmore
18:33   A1   4   Ardera Laval
18:49   A1   3   Nice Rebel

Pelaw Grange
19:30   A8   5   Swift Zeus
20:08   A7   4   Dalton Daley

Perry Barr
19:40   A2   2   Skinny Joe
20:16   A1   4   Best Dressed
21:10   HP   6   Stoneparkwarrior

Hove
20:06   A6   6   Regeva Smiler
20:53   A4   6   Feora Star

Swindon
20:04   A2   1   Harrys Daydream
21:24   A7   3   Bravo Honey

Poole
20:09   A6   6   Spire And Mire
21:41   HP   6   Seavale Lad
21:58   A8   1   Honeygar Sonia
22:30   A3   2   Ballyoak Maggie

Belle Vue
20:11   A10   1   Ballyphilip Moll
22:05   A1   3   Rockmount Buster

Peterborough
20:51   A8   5   Yulia
22:30   A3   4   Itsybitsey Bear

Shawfield
21:33   HP   4   Millie The Minx
22:00   HP   2   Go Skye Go

Nottingham
21:01   HP   5   Outlaw Yahoo

These are my LTB Trades for Sat Mar 14:
Romford
10:29   A9   5   Waikiki Lass
11:27   A4   5   Underground Pixi
11:43   A6   2   Tinas Survivor
11:59   A1   4   Bit View Nala
12:28   A3   2   Foxy Thing
12:44   A6   5   Brickleberry
13:28   A2   3   Bubbly Betty
18:56   A2   3   Kind Secret
19:44   A3   3   Formel Scotty
19:59   A3   4   To Tone Dan
20:48   A1   2   Lemon Tas
21:03   A1   3   Princess Zara
21:58   S4   4   Mays Ballyhill

Crayford
11:06   A7   2   Deanridge Blewit
12:06   A8   3   Mines A Malbec
12:54   A6   3   Barnfield Cosmo
13:22   A2   3   Mums The Best
20:00   A1   1   Cronody Flash
20:51   A5   5   Minesacoorslight

Newcastle
14:59   A7   5   Wazokie Flight
17:27   A7   5   Watermill Vic
17:44   A8   2   Burleigh Heads
17:59   A6   2   Commitment Issue
20:04   A1   2   Burgess Paddy
20:19   A5   4   Jumeirah Tango

Henlow
14:28   A5   4   Makeit Hugo
14:48   A3   6   Indigo Sandy
15:07   A5   6   Droopys Crystal
18:03   A9   3   Empire King
18:18   A9   4   Victory Applause

Doncaster
16:57   B7   1   Pink Mags

Monmore
18:33   A1   2   Mitchells Angel
18:49   A1   5   Greenhill Jack
19:54   D1   4   Urney Jackson

Yarmouth
19:15   A9   4   Gottabe Larkins
19:45   A4   4   Hartwood Bandit

Pelaw Grange
20:08   A7   1   Susies Call
20:27   A1   6   Dublinhill Blitz

Perry Barr
19:40   A2   1   Emers Pirate
21:10   HP   2   Cohens Star

Hove
19:49   A2   2   Sharp Katie
20:06   A6   5   Malbay Willow
20:53   A4   4   Chaotic Des
22:02   A3   3   Fooster

Swindon
20:04   A2   5   Lauragh Erin
21:24   A7   5   Juliet Says

Poole
20:09   A6   1   Baltovin Fury
21:41   HP   1   Juliet Recruit
21:58   A8   4   Dashing Through

Belle Vue
20:11   A10   2   Shaneboy Madrid

Peterborough
22:30   A3   3   Fengate Gaffer

Shawfield
20:53   HP   2   Ballyhone Fox
21:33   HP   5   Headford Recruit
22:00   HP   3   Boolabeg Lad

Nottingham
21:01   HP   1   Iveshead Willow

Kinsley
21:44   A4   3   Plentyinthetank
Post Reply

Return to “Other Betfair Sports Trading markets”