Created
November 20, 2022 01:12
-
-
Save vlaskz/2a6edee3b3b3fceec331b0a6b73defb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from selenium import webdriver | |
| from selenium.webdriver import Keys | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.firefox.options import Options | |
| from collections import Counter | |
| def get_numbers(driver): | |
| objs = driver.find_elements(By.CSS_SELECTOR, 'li.ng-binding') | |
| numbers = [int(i.text) for i in objs] | |
| # print(numbers) | |
| return numbers | |
| def get_contest(contest, driver): | |
| result = driver.find_element(By.ID, 'buscaConcurso') | |
| result.clear() | |
| result.send_keys(contest, Keys.ENTER) | |
| if __name__ == '__main__': | |
| opt = Options() | |
| # opt.headless = True | |
| driver = webdriver.Firefox(options=opt) | |
| url = 'https://loterias.caixa.gov.br/Paginas/Lotofacil.aspx' | |
| driver.maximize_window() | |
| time.sleep(2) | |
| driver.get(url) | |
| last_draw = int( | |
| driver.find_element( | |
| By.CSS_SELECTOR, '.title-bar > h2:nth-child(2) > span:nth-child(1)').text.split(' ')[1]) | |
| time.sleep(8) | |
| # driver.find_element(By.CLASS_NAME, 'resultado-loteria').click() | |
| # get_numbers(driver) | |
| # | |
| # get_contest(1000, driver) | |
| results = list() | |
| total_hits = list() | |
| i = 1 | |
| last_numbers = list() | |
| ratio = { | |
| "Win": 1, | |
| "Lose": 1, | |
| "Ratio": 0.0 | |
| } | |
| balance = 0.0 | |
| while i < last_draw + 1: | |
| try: | |
| get_contest(i, driver) | |
| nums = get_numbers(driver) | |
| if nums == last_numbers: | |
| pass | |
| else: | |
| last_numbers = nums | |
| results.extend(nums) | |
| most_common = sorted([int(i[0]) for i in Counter(results).most_common(15)]) | |
| hits = 15 - len(set(nums) - set(most_common)) | |
| total_hits.append(hits) | |
| hits_per_hit = Counter(total_hits).most_common() | |
| status = 'Win' if hits > 10 else 'Lose' | |
| ratio[status] += 1 | |
| ratio['Ratio'] = ratio['Win'] / ratio['Lose'] | |
| if hits == 11: | |
| balance += 2.5 | |
| elif hits == 12: | |
| balance += 7.5 | |
| elif hits == 13: | |
| balance += 25 | |
| elif hits > 13: | |
| print('JACKPOT $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$') | |
| elif hits < 11: | |
| balance -=2.5 | |
| print(f'Concurso: {i} de {last_draw}', | |
| f'Dezenas: {nums}', | |
| f'Mais freqs.: {most_common}', | |
| f'Acertos: {hits}', | |
| f'Status: {status}', | |
| f'Spread(V/D): {ratio}', | |
| f'Saldo: {balance}', | |
| f'Acertos por acerto: {hits_per_hit}' | |
| ) | |
| i += 1 | |
| except Exception as e: | |
| pass | |
| print(f'{last_draw}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment