-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (44 loc) · 1.48 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
from selenium.webdriver import Chrome
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
import telepot
import time
bot = telepot.Bot('bot-telegram-token')
driver_options = Options()
driver_options.add_argument('--headless')
driver_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', options=driver_options)
driver.get('https://agenda.vacunacioncovid.gub.uy/')
def slow_typing(element, text):
for character in text:
element.send_keys(character)
time.sleep(0.3)
def ci():
ci = driver.find_element_by_id('numberCID')
slow_typing(ci, 'ci_number')
def db():
daybirth = driver.find_element_by_name('dateBirth[day]')
slow_typing(daybirth, 'xx')
def mb():
monthbirth = Select(driver.find_element_by_id('mes'))
monthbirth_selected = monthbirth.select_by_visible_text("noviembre")
def yb():
daybirth = driver.find_element_by_name('dateBirth[year]')
slow_typing(daybirth, 'xxxx')
def sb():
submit = driver.find_element_by_id('btnCheckData')
submit.click()
def screenshot():
time.sleep(3)
screenshot = driver.save_screenshot("screenshot.png")
def message():
bot.sendMessage(-chat_id, 'Acabo de chequear si puedes vacunarte')
bot.sendPhoto(-chat_id, photo=open('screenshot.png', 'rb'))
ci()
db()
mb()
yb()
sb()
screenshot()
message()