Skip to content

Instantly share code, notes, and snippets.

@montali
Last active June 15, 2021 12:57
Show Gist options
  • Save montali/1bdd0d5a4ea4b8477c1837d93cb7171a to your computer and use it in GitHub Desktop.
Save montali/1bdd0d5a4ea4b8477c1837d93cb7171a to your computer and use it in GitHub Desktop.
Vaccine booker built on SeleniumPy. Keeps refreshing CupWeb until a vaccine is available.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.firefox.options import Options
from telegram import ParseMode
from telegram.ext import Updater, CommandHandler
from time import sleep, time
from datetime import datetime
TOKEN = "yourtelegramtoken" # Insert your Telegram token here, as sent by @BotFather
CHAT = 000000 # Sending /start to the bot will print the chat ID in the terminal
def start(update, context):
'''reply to /start cmd'''
print(update.message.chat_id)
context.bot.send_message(chat_id=update.message.chat_id,
text="Correctly printed your chat ID\n")
def do_it():
driver.get("https://www.fascicolo-sanitario.it/fse/wicket/page?2")
driver.find_elements_by_id("btn_erogazione_farmaci")[1].click()
driver.find_element_by_class_name("tbElenco").find_element_by_class_name(
"pari").find_element_by_tag_name("input").click()
driver.find_element_by_id("_target2").click()
driver.find_element_by_id("_target4").click()
page = driver.find_element_by_id(
"datawizard").get_attribute("innerHTML").lower()
prev_page = page
while page == prev_page:
sleep(20)
driver.find_element_by_id("_target3").click()
driver.find_element_by_id("_target4").click()
prev_page = page
page = driver.find_element_by_id(
"datawizard").get_attribute("innerHTML").lower()
print("πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚ Difference!! πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚πŸš‚")
updater.bot.send_message(
chat_id=CHAT, text="Fai andare fra")
options = Options()
options.headless = False
driver = webdriver.Firefox(options=options)
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", start))
updater.start_polling()
driver.get("https://www.fascicolo-sanitario.it/")
driver.implicitly_wait(10)
print("πŸš‚ You now got 30 seconds to log in")
sleep(30)
while input("Wanna go?") == "y":
do_it()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment