This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
111 lines (94 loc) · 4.77 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from bs4 import BeautifulSoup
from selenium import webdriver
import json
import telegram
import schedule
"""
Algoritmo de Captura de dados
"""
colorPath = []
LastCommand = ""
api_key = 'SEU TOKEN'
user_id = 'SEU ID'
bot = telegram.Bot(token=api_key)
ultima_cor = ['']
def sequenceColor(color, vezes):
cont = 0;
for c in colorPath:
if c == color:
cont = cont + 1
if cont == int(vezes):
return True
else:
return False
def verifyIfNeedAlarm():
print(colorPath)
with open("./configuracao.json", encoding='utf-8') as meu_json:
dados = json.load(meu_json)
for i in dados:
cor = i['cor']
vezes = i['vezes']
jogar = i['jogar']
emote = i['emote']
mensagem = i['mensagem']
if sequenceColor(cor, vezes):
if jogar == "vermelho":
print(jogar)
bot.send_message(chat_id=user_id, text=f'Sequencia: [{colorPath[0], colorPath[1], colorPath[2], colorPath[3]}]\n{mensagem} {emote}')
return
else:
print(jogar)
bot.send_message(chat_id=user_id, text=f'Sequencia: [{colorPath[0], colorPath[1], colorPath[2], colorPath[3]}]\n{mensagem} {emote}')
return
def startVerification():
# Opções para deixar o navegador mais rapido
options = webdriver.FirefoxOptions()
options.add_argument('--headless')
options.add_argument('--log-level=3')
profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.pipelining", True)
profile.set_preference("network.http.proxy.pipelining", True)
profile.set_preference("network.http.pipelining.maxrequests", 8)
profile.set_preference("content.notify.interval", 500000)
profile.set_preference("content.notify.ontimer", True)
profile.set_preference("content.switch.threshold", 250000)
profile.set_preference("browser.cache.memory.capacity", 65536) # Increase the cache capacity.
profile.set_preference("browser.startup.homepage", "about:blank")
profile.set_preference("reader.parse-on-load.enabled", False) # Disable reader, we won't need that.
profile.set_preference("browser.pocket.enabled", False) # Duck pocket too!
profile.set_preference("loop.enabled", False)
profile.set_preference("browser.chrome.toolbar_style", 1) # Text on Toolbar instead of icons
profile.set_preference("browser.display.show_image_placeholders", False) # Don't show thumbnails on not loaded images.
profile.set_preference("browser.display.use_document_colors", False) # Don't show document colors.
profile.set_preference("browser.display.use_document_fonts", 0) # Don't load document fonts.
profile.set_preference("browser.display.use_system_colors", True) # Use system colors.
profile.set_preference("browser.formfill.enable", False) # Autofill on forms disabled.
profile.set_preference("browser.helperApps.deleteTempFileOnExit", True) # Delete temprorary files.
profile.set_preference("browser.shell.checkDefaultBrowser", False)
profile.set_preference("browser.startup.homepage", "about:blank")
profile.set_preference("browser.startup.page", 0) # blank
profile.set_preference("browser.tabs.forceHide", True) # Disable tabs, We won't need that.
profile.set_preference("browser.urlbar.autoFill", False) # Disable autofill on URL bar.
profile.set_preference("browser.urlbar.autocomplete.enabled", False) # Disable autocomplete on URL bar.
profile.set_preference("browser.urlbar.showPopup", False) # Disable list of URLs when typing on URL bar.
profile.set_preference("browser.urlbar.showSearch", False) # Disable search bar.
profile.set_preference("extensions.checkCompatibility", False) # Addon update disabled
profile.set_preference("extensions.checkUpdateSecurity", False)
profile.set_preference("extensions.update.autoUpdateEnabled", False)
profile.set_preference("extensions.update.enabled", False)
profile.set_preference("general.startup.browser", False)
profile.set_preference("plugin.default_plugin_disabled", False)
profile.set_preference("permissions.default.image", 2) # Image load disabled again
browser = webdriver.Firefox(firefox_profile=profile,options=options, executable_path='./geckodriver')
browser.get("https://blaze.com/pt/games/double")
html = browser.page_source
browser.quit()
soup = BeautifulSoup(html, features="html.parser").div
colors = soup.findAll("div", class_="sm-box")
for color in colors:
colorPath.append(color['class'][1])
verifyIfNeedAlarm()
schedule.every(4).seconds.do(startVerification)
while 1:
schedule.run_pending()
colorPath.clear()