Skip to content

Commit

Permalink
fixed bugz
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-pollak committed Feb 17, 2021
1 parent 4416ed3 commit 9bbb015
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
1 change: 0 additions & 1 deletion matcher/betfair_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import datetime
import json
import os
Expand Down
9 changes: 4 additions & 5 deletions matcher/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ def update_csv_betfair(race, sporting_index_balance, bookie_stake, win_stake,

def reset_csv():
now = datetime.now().strftime('%d-%m-%Y')
returns_header = 'date_of_race,horse_name,bookie_odds,venue,ew_stake,balance,rating,current_time,expected_value,expected_return,win_stake,place_stake,win_odds,place_odds,betfair_balance,max_profit,is_lay,win_matched,lay_matched,arbritrage_profit,place_payout'
RETURNS_HEADER = 'date_of_race,horse_name,bookie_odds,venue,ew_stake,balance,rating,current_time,expected_value,expected_return,win_stake,place_stake,win_odds,place_odds,betfair_balance,max_profit,is_lay,win_matched,lay_matched,arbritrage_profit,place_payout'
RETURNS_BAK = os.path.join(BASEDIR, 'stats/returns-%s.csv' % now)

create_new_returns = input(
'Create new return.csv? (Recommended for new user) [Y]/n ').lower()

if create_new_returns != 'n':
os.rename(RETURNS_CSV, RETURNS_BAK)
f = open(RETURNS_CSV, 'w')
f.write(returns_header)
f.close()
print('Created new csv.')
with open(RETURNS_CSV, 'w', newline='') as returns_csv:
returns_csv.write(RETURNS_HEADER)
print('Created new returns.csv')
34 changes: 17 additions & 17 deletions matcher/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
raise Exception('client-2048 certificates not found')


def login():
def login(driver):
driver.get('https://www.oddsmonkey.com/oddsmonkeyLogin.aspx?returnurl=%2f')
try:
WebDriverWait(driver, 60).until(
Expand Down Expand Up @@ -78,23 +78,23 @@ def login():
def run_matcher():
print(f'Started at: {datetime.now().strftime("%H:%M:%S %d/%m/%Y")}')
while True:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(
"user-agent=Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36"
)
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--remote-debugging-port=9222") # this
chrome_options.add_argument("--disable-dev-shm-using")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("start-maximized")
prefs = {"profile.default_content_setting_values.notifications": 2}
chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=chrome_options)
sys.stdout.flush()
try:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(
"user-agent=Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36"
)
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--remote-debugging-port=9222") # this
chrome_options.add_argument("--disable-dev-shm-using")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("start-maximized")
prefs = {"profile.default_content_setting_values.notifications": 2}
chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=chrome_options)
sys.stdout.flush()
login()
login(driver)
scrape(driver)
except ValueError as e:
sys.stdout.flush()
Expand Down

0 comments on commit 9bbb015

Please sign in to comment.