From b3c6bcca209bb46070805c1bf1f0eb30a1c554c4 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:30:39 +0200 Subject: [PATCH 1/7] Use https --- kicktippbb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kicktippbb.py b/kicktippbb.py index 3614ae5f..6954c0a6 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -37,7 +37,7 @@ from helper.deadline import is_before_dealine, timedelta_tostring from helper.match import Match -URL_BASE = 'http://www.kicktipp.de' +URL_BASE = 'https://www.kicktipp.de' URL_LOGIN = URL_BASE + '/info/profil/login' DEADLINE_REGEX = re.compile('([1-9][0-9]*)(m|h|d)') From d0bac5a0cda0783a075514c5286f4bf1c9f08309 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:32:01 +0200 Subject: [PATCH 2/7] Allow uppercase communities --- kicktippbb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kicktippbb.py b/kicktippbb.py index 6954c0a6..f97a2277 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -154,7 +154,7 @@ def gethreftext(link): return link.get('href').replace("/", "") def is_community(link): hreftext = gethreftext(link) - if hreftext == link.get_text(): + if hreftext == link.get_text().lower(): return True else: linkdiv = link.find('div', {'class': "menu-title-mit-tippglocke"}) From 57e9be50e12704c88bb18729eab2b5541233c4b6 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:56:30 +0200 Subject: [PATCH 3/7] Change some comments --- kicktippbb.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kicktippbb.py b/kicktippbb.py index f97a2277..3ec234cd 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -1,8 +1,8 @@ """KickTipp BetBot Automated kicktipp.de bet placement. -Places bets to the upcomming matchday. -Unless specified by parameter it places the bets on all prediction games of the account. +Places bets for the upcoming matchday. +Unless specified by parameter, it places the bets on all prediction games of the account. Usage: kicktippbb.py [ --get-login-token ] @@ -12,7 +12,7 @@ Options: COMMUNITY Name of the prediction game community to place bets on, one or more names can be specified. - If no community name is given all available communities will be considered. + If no community name is given, all available communities will be considered. --get-login-token Just login and print the login token string for later use with '--use-login-token' option --use-login-token Perform bets without interactive login, use login token instead. @@ -21,7 +21,7 @@ The duration format is , e.g. 10m,5h or 1d --list-predictors Display a list of predictors available to be used with '--predictor' option --predictor A specific predictor name to be used during calculation - --dry-run Dont place any bet just print out predicitons + --dry-run Don't place any bet just print out predictions --matchday Choose a specific matchday in the range of 1 to 34 to place bets on """ @@ -45,7 +45,7 @@ def login(browser: RoboBrowser): """Log into the user account by asking for username and password. - If login succeded the login cookie token is returned + If login succeeded the login cookie token is returned """ while True: username, password = get_credentials() @@ -58,7 +58,7 @@ def login(browser: RoboBrowser): def perform_login(browser: RoboBrowser, username: str, password: str): """ - Open the log in page then fill out the form and submit + Open the login page then fill out the form and submit """ browser.open(URL_LOGIN) form = browser.get_form() @@ -94,10 +94,10 @@ def get_table_rows(soup): def parse_match_rows(browser: RoboBrowser, community, matchday = None): """Fetch latest odds for each match - Returns a list of tuples (heimtipp,gasttipp, match) + Returns a list of tuples (heimtipp, gasttipp, match) """ browser.open(get_tippabgabe_url(community, matchday)) - + content = get_kicktipp_content(browser) rows = get_table_rows(content) @@ -222,7 +222,7 @@ def choose_predictor(predictor_param, predictors): else: exit('Unknown predictor: {}'.format(predictor_param)) else: - # Just get the first predictor in the dict and instanciate it + # Just get the first predictor in the dict and instantiate it predictor = next(iter(predictors.values()))() print("Using predictor: "+type(predictor).__name__) return predictor @@ -255,7 +255,7 @@ def main(arguments): # Just use the token for all interactions with the website browser.session.cookies['login'] = token - # Which communities are considered, fail if no were found + # Which communities are considered, fail if none were found communities = get_communities(browser, communities) if(len(communities) == 0): exit("No community found!?") From 255c15c1c655fd6b41bab50b3969d4df5c8e0374 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:58:41 +0200 Subject: [PATCH 4/7] New delimiter symbol --- kicktippbb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kicktippbb.py b/kicktippbb.py index 3ec234cd..6e09291e 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -109,7 +109,7 @@ def parse_match_rows(browser: RoboBrowser, community, matchday = None): gasttipp = row[3].find( 'input', id=lambda x: x and x.endswith('_gastTipp')) try: - odds=[odd.replace(" ","") for odd in row[4].get_text().split("/")] + odds=[odd.replace(" ","") for odd in row[4].get_text().split("|")] match = Match(row[1].get_text(), row[2].get_text(), row[0].get_text( ), odds[0], odds[1], odds[2]) except: From a82892df415b7812b332a0f95c7cd9262453b1a1 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Sat, 26 Aug 2023 19:01:56 +0200 Subject: [PATCH 5/7] General formatting --- kicktippbb.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/kicktippbb.py b/kicktippbb.py index 6e09291e..17b242af 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -92,7 +92,7 @@ def get_table_rows(soup): return [tr.find_all('td') for tr in tbody.find_all('tr')] -def parse_match_rows(browser: RoboBrowser, community, matchday = None): +def parse_match_rows(browser: RoboBrowser, community, matchday=None): """Fetch latest odds for each match Returns a list of tuples (heimtipp, gasttipp, match) """ @@ -109,7 +109,7 @@ def parse_match_rows(browser: RoboBrowser, community, matchday = None): gasttipp = row[3].find( 'input', id=lambda x: x and x.endswith('_gastTipp')) try: - odds=[odd.replace(" ","") for odd in row[4].get_text().split("|")] + odds = [odd.replace(" ", "") for odd in row[4].get_text().split("|")] match = Match(row[1].get_text(), row[2].get_text(), row[0].get_text( ), odds[0], odds[1], odds[2]) except: @@ -122,7 +122,8 @@ def parse_match_rows(browser: RoboBrowser, community, matchday = None): return matchtuple -def get_tippabgabe_url(community, matchday = None): + +def get_tippabgabe_url(community, matchday=None): tippabgabeurl = URL_BASE + '/' + community + '/tippabgabe' if matchday is None: return tippabgabeurl @@ -150,7 +151,9 @@ def get_communities(browser: RoboBrowser, desired_communities: list): browser.open(URL_BASE + '/info/profil/meinetipprunden') content = get_kicktipp_content(browser) links = content.find_all('a') - def gethreftext(link): return link.get('href').replace("/", "") + + def gethreftext(link): + return link.get('href').replace("/", "") def is_community(link): hreftext = gethreftext(link) @@ -159,6 +162,7 @@ def is_community(link): else: linkdiv = link.find('div', {'class': "menu-title-mit-tippglocke"}) return linkdiv and linkdiv.get_text() == hreftext + community_list = [gethreftext(link) for link in links if is_community(link)] if len(desired_communities) > 0: @@ -216,15 +220,15 @@ def validate_arguments(arguments): def choose_predictor(predictor_param, predictors): - if(predictor_param): - if(predictor_param in predictors): + if (predictor_param): + if (predictor_param in predictors): predictor = predictors[predictor_param]() else: exit('Unknown predictor: {}'.format(predictor_param)) else: # Just get the first predictor in the dict and instantiate it predictor = next(iter(predictors.values()))() - print("Using predictor: "+type(predictor).__name__) + print("Using predictor: " + type(predictor).__name__) return predictor @@ -257,7 +261,7 @@ def main(arguments): # Which communities are considered, fail if none were found communities = get_communities(browser, communities) - if(len(communities) == 0): + if (len(communities) == 0): exit("No community found!?") # Which prediction method is used From d5031c5e0aad352d364639b875ee5544035b3f98 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Fri, 15 Mar 2024 21:12:11 +0100 Subject: [PATCH 6/7] Update delimiter --- kicktippbb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kicktippbb.py b/kicktippbb.py index 17b242af..977e214c 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -109,7 +109,7 @@ def parse_match_rows(browser: RoboBrowser, community, matchday=None): gasttipp = row[3].find( 'input', id=lambda x: x and x.endswith('_gastTipp')) try: - odds = [odd.replace(" ", "") for odd in row[4].get_text().split("|")] + odds = [odd.replace(" ", "") for odd in row[4].get_text().replace("Quote:", "").split("/")] match = Match(row[1].get_text(), row[2].get_text(), row[0].get_text( ), odds[0], odds[1], odds[2]) except: @@ -175,7 +175,8 @@ def intersection(a, b): return i -def place_bets(browser: RoboBrowser, communities: list, predictor, override=False, deadline=None, dryrun=False, matchday=None): +def place_bets(browser: RoboBrowser, communities: list, predictor, override=False, deadline=None, dryrun=False, + matchday=None): """Place bets on all given communities.""" for com in communities: print("Community: {0}".format(com)) @@ -270,7 +271,8 @@ def main(arguments): # Place bets place_bets(browser, communities, predictor, - override=arguments['--override-bets'], deadline=arguments['--deadline'], dryrun=arguments['--dry-run'], matchday=arguments['--matchday']) + override=arguments['--override-bets'], deadline=arguments['--deadline'], dryrun=arguments['--dry-run'], + matchday=arguments['--matchday']) if __name__ == '__main__': From 6d1eeb16937f249317fec357601218d5ae46e4b7 Mon Sep 17 00:00:00 2001 From: Wxrlds <42120270+Wxrlds@users.noreply.github.com> Date: Fri, 10 May 2024 12:03:47 +0200 Subject: [PATCH 7/7] Fix not finding communities --- kicktippbb.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/kicktippbb.py b/kicktippbb.py index 977e214c..62295ae6 100644 --- a/kicktippbb.py +++ b/kicktippbb.py @@ -161,7 +161,7 @@ def is_community(link): return True else: linkdiv = link.find('div', {'class': "menu-title-mit-tippglocke"}) - return linkdiv and linkdiv.get_text() == hreftext + return linkdiv and linkdiv.get_text().lower() == hreftext community_list = [gethreftext(link) for link in links if is_community(link)] @@ -175,8 +175,7 @@ def intersection(a, b): return i -def place_bets(browser: RoboBrowser, communities: list, predictor, override=False, deadline=None, dryrun=False, - matchday=None): +def place_bets(browser: RoboBrowser, communities: list, predictor, override=False, deadline=None, dryrun=False, matchday=None): """Place bets on all given communities.""" for com in communities: print("Community: {0}".format(com)) @@ -190,15 +189,13 @@ def place_bets(browser: RoboBrowser, communities: list, predictor, override=Fals input_hometeam_value = submitform[field_hometeam.attrs['name']].value input_roadteam_value = submitform[field_roadteam.attrs['name']].value if not override and (input_hometeam_value or input_roadteam_value): - print("{0} - skipped, already placed {1}:{2}".format(match, - input_hometeam_value, input_roadteam_value)) + print("{0} - skipped, already placed {1}:{2}".format(match, input_hometeam_value, input_roadteam_value)) continue if deadline is not None: if not is_before_dealine(deadline, match.match_date): time_to_match = match.match_date - datetime.datetime.now() - print("{0} - not betting yet, due in {1}".format(match, - timedelta_tostring(time_to_match))) + print("{0} - not betting yet, due in {1}".format(match, timedelta_tostring(time_to_match))) continue homebet, roadbet = predictor.predict(match) @@ -270,9 +267,7 @@ def main(arguments): predictor = choose_predictor(predictor_param, predictors_) # Place bets - place_bets(browser, communities, predictor, - override=arguments['--override-bets'], deadline=arguments['--deadline'], dryrun=arguments['--dry-run'], - matchday=arguments['--matchday']) + place_bets(browser, communities, predictor, override=arguments['--override-bets'], deadline=arguments['--deadline'], dryrun=arguments['--dry-run'], matchday=arguments['--matchday']) if __name__ == '__main__':