728x90
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
from random import *
from datetime import datetime
import telegram
import re

def cleanhtml(raw_html):
  cleanr = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});')
  cleantext = re.sub(cleanr, '', raw_html)
  return cleantext

bot = telegram.Bot(token='')
chat_id = ''

ID = ""
PW = "!"
target_date="27" #원하는 날짜

bot.sendMessage(chat_id, datetime.today().strftime("%Y/%m/%d %H:%M:%S")+" 더힐CC "+target_date+"일 예약 START")


chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

browser = webdriver.Chrome(executable_path="/usr/bin/chromedriver",chrome_options=chrome_options)

time.sleep(1)
#로그인 처리
search = browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_txtUserID"]')
search.send_keys(ID)

search = browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_txtPassword"]')
search.send_keys(PW)
search.send_keys(Keys.RETURN)

time.sleep(3)


time.sleep(3)

while True:
    try:  
        for i in range(1,6):
            for j in range(1,8):
                search_row = browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_UpPanel1"]/div/div/div[2]/div[1]/div[1]/table/tbody/tr['+str(i)+']/td['+str(j)+']')
                search_row_innerhtml = search_row.get_attribute('innerHTML')


                cleaned_search_row = search_row_innerhtml.lstrip().rstrip().replace("    ","")
               
                if cleaned_search_row.find("Update") >= 0:
                   
                    if cleaned_search_row.find(target_date) >= 0:
                        try:
                            search = browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_UpPanel1"]/div/div/div[2]/div[2]/div[3]/table/tbody/tr/td[6]/a')  
                            search.send_keys(Keys.RETURN)
                            bot.sendMessage(chat_id, datetime.today().strftime("%Y/%m/%d %H:%M:%S")+" 더힐CC "+target_date+"일 예약")
                        except:
                            try:
                                search = browser.find_element_by_xpath('//*[@id="ctl00_ContentPlaceHolder1_UpPanel1"]/div/div/div[2]/div[2]/div[3]/table/tbody/tr[1]/td[6]/a')  
                                search.send_keys(Keys.RETURN)
                                bot.sendMessage(chat_id, datetime.today().strftime("%Y/%m/%d %H:%M:%S")+" 더힐CC "+target_date+"일 예약")
                            except:
                                browser.refresh()
                                time.sleep(7)
                if i*j == 35:
                    print(datetime.today().strftime("%Y/%m/%d %H:%M:%S")+' 더힐 cc > '+cleaned_search_row)
                    browser.refresh()
                    time.sleep(7)
    except:
        print("exception occured!")
        browser.refresh()
        time.sleep(7)
728x90

+ Recent posts