Greyhound Mystique

Any markets not covered in the other boards
Post Reply
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

I have it scheduled to run at 9:30, just checked my DB and looks like it ran fine.

edit:

Just ran the code posted yesterday and the line

Code: Select all

if bool(Runners) == True and ('OR' in grade or 'A' in grade):
needed amending to

Code: Select all

if bool(Runners) == True and ('OR' in grade or 'A' in grade) and len(Runners.items())>1:
Probably so many scrappy snippets of the code on the thread at the moment.

Code: Select all

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


def main():
    session = HTMLSession()
    baseUrl = "https://www.sportinglife.com"
    results=[]
    urls = []
    res = requests.get("https://www.sportinglife.com/greyhounds/racecards")
    soup = BeautifulSoup(res.text, "html.parser")
    data =json.loads( soup.find('script', type='application/json').string) #convert to dictionary


    for market in data['props']['pageProps']['meetings']:
        
        for race in market['races']:
            if race['race_stage'] == "Dormant":
                urls.append('/greyhounds/racecards/' + race['date'] + '/' + race['course_name'].replace(" ", "-") + '/racecard/' + str(race['race_summary_reference']['id']))
    
    x = 0
    for link in urls:
        
        res = session.get(baseUrl + link)
        print(baseUrl + link)
        soup = BeautifulSoup(res.text, "html.parser")
        data =json.loads( soup.find('script', type='application/json').string)
       
        grade = data['props']['pageProps']['race']['race_summary']['race_class']
        distance = data['props']['pageProps']['race']['race_summary']['distance']
        course = data['props']['pageProps']['race']['race_summary']['course_name']
        race = data['props']['pageProps']['race']['race_summary']['date'] + "," + data['props']['pageProps']['race']['race_summary']['time'] + " " + course
        Runners = dict()
        print((baseUrl + link))
        
        data =json.loads( soup.find('script', type='application/json').string) #convert to dictionary
        
        for runner in data['props']['pageProps']['race']['runs']:
            
            
            Trap = runner['cloth_number']
            Name = runner['greyhound']['name']
            
            fastest_time=100
            for time in runner['greyhound']['previous_results']:
               
                if  'distance'  in time.keys() and time['distance'] == distance and time['run_time'] !="":
                   
                    
                    if float(time['run_time'].strip("s")) <= fastest_time:
                        
                        fastest_time=float(time['run_time'].strip("s"))
                    

            
            Runners[fastest_time] = str(Trap) + '. ' + Name
                        
         
        if bool(Runners) == True and ('OR' in grade or 'A' in grade) and len(Runners.items())>1:
            
            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)
                results.append(race + ', ' + x[0][1] + ', class ' + grade + ', time difference ' + str(timeDiff))
    results.sort()
    file = open('dogs_1.txt', mode='w')
    for line in results: file.write(line+'\n')
    file.close()
    
main()
User avatar
murdok
Posts: 151
Joined: Sun Apr 02, 2017 7:10 pm

already working again and thanks ;)
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

Python will usually tell you which lines of code are falling over so should hopefully be fine till the next time it encounters an unexpected error. Certainly can't see Sporting life being arsed to re-write the site to close down a script that maybe a max of 5 people use and the scraping is more data efficient than people having to look thru each page for the data also.
User avatar
MemphisFlash
Posts: 2126
Joined: Fri May 16, 2014 10:12 pm
Location: Leicester

how do you work this in pyhton?
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

Have you installed python? From there it's no more than than running python then open the file (File->Open) using the program and select Run (Run->Run Module F5).

Untitled.png


If you instal python to PATH it means you can run it from the command line alot easier also, so worth doing when you instal python

https://stackoverflow.com/questions/349 ... on-to-path

https://www.python.org/downloads/
tenso
Posts: 2
Joined: Wed Jan 06, 2021 1:35 am

Thank spreadbetting
User avatar
MemphisFlash
Posts: 2126
Joined: Fri May 16, 2014 10:12 pm
Location: Leicester

this is what i have, getting an error message that i have no idea what it is
Capture.JPG
You do not have the required permissions to view the files attached to this post.
spreadbetting
Posts: 3140
Joined: Sun Jan 31, 2010 8:06 pm

Is that character with the triabgle poting to top at the bottom of your code? Have you pasted something in inadvertently, if so delete it , or maybe delete any spaces in the filename itself.
User avatar
MemphisFlash
Posts: 2126
Joined: Fri May 16, 2014 10:12 pm
Location: Leicester

yes that was it, didnt even see it myself.
many thanks for that.
got it working now.
User avatar
MemphisFlash
Posts: 2126
Joined: Fri May 16, 2014 10:12 pm
Location: Leicester

Looks like someone trying to steal the idea Archery1969

https://www.youtube.com/watch?v=a4w2z1L ... e=emb_logo
Capture.JPG
You do not have the required permissions to view the files attached to this post.
Archery1969
Posts: 3193
Joined: Thu Oct 24, 2019 8:25 am
Location: Newport

MemphisFlash wrote:
Tue Jan 12, 2021 8:37 am
Looks like someone trying to steal the idea Archery1969

https://www.youtube.com/watch?v=a4w2z1L ... e=emb_logo

Capture.JPG
Only £69.97 :o

I got bombarded with emails from him some months back. Have no clue how he got my email address.

That bloke is an utter scumbag. :oops:
User avatar
jimibt
Posts: 3641
Joined: Mon Nov 30, 2015 6:42 pm
Location: Narnia

Archery1969 wrote:
Tue Jan 12, 2021 9:37 am
MemphisFlash wrote:
Tue Jan 12, 2021 8:37 am
Looks like someone trying to steal the idea Archery1969

https://www.youtube.com/watch?v=a4w2z1L ... e=emb_logo

Capture.JPG
Only £69.97 :o

I got bombarded with emails from him some months back. Have no clue how he got my email address.

That bloke is an utter scumbag. :oops:
we all thought it was YOU - :D :D
User avatar
The Silk Run
Posts: 902
Joined: Mon May 14, 2018 12:53 am
Location: United Kingdom

jimibt wrote:
Tue Jan 12, 2021 9:39 am
Archery1969 wrote:
Tue Jan 12, 2021 9:37 am
MemphisFlash wrote:
Tue Jan 12, 2021 8:37 am
Looks like someone trying to steal the idea Archery1969

https://www.youtube.com/watch?v=a4w2z1L ... e=emb_logo

Capture.JPG
Only £69.97 :o

I got bombarded with emails from him some months back. Have no clue how he got my email address.

That bloke is an utter scumbag. :oops:
we all thought it was YOU - :D :D
Your WRONG JB. It's Derek :o
Archery1969
Posts: 3193
Joined: Thu Oct 24, 2019 8:25 am
Location: Newport

jimibt wrote:
Tue Jan 12, 2021 9:39 am
Archery1969 wrote:
Tue Jan 12, 2021 9:37 am
MemphisFlash wrote:
Tue Jan 12, 2021 8:37 am
Looks like someone trying to steal the idea Archery1969

https://www.youtube.com/watch?v=a4w2z1L ... e=emb_logo

Capture.JPG
Only £69.97 :o

I got bombarded with emails from him some months back. Have no clue how he got my email address.

That bloke is an utter scumbag. :oops:
we all thought it was YOU - :D :D
Mine would have been £1.99 Jim. With a 50% discount if ordered before midnight. :lol:
User avatar
wearthefoxhat
Posts: 3206
Joined: Sun Feb 18, 2018 9:55 am

copy2.png
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Other Betfair Sports Trading markets”