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
| import time from selenium import webdriver import telegram
def updateStatus(): browser.find_element_by_xpath('//*[@id="paramInvcNo"]').send_keys(num) browser.find_element_by_xpath('//*[@id="btnSubmit"]').click() status = browser.find_element_by_xpath('//*[@id="statusDetail"]') return status.text
options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('window-size=1920x1080') options.add_argument("disable-gpu") browser = webdriver.Chrome("Location of Chrome Driver", options = options) browser.implicitly_wait(5) url = 'https://www.cjlogistics.com/ko/tool/parcel/tracking' browser.get(url) myToken = 'TelegramToken' bot = telegram.Bot(token = myToken) chat_id = ID num = 운송장 번호 statusArr = ["", ""]
i = 0 while True: status = updateStatus() statusArr[i%2] = str(status) if statusArr[0] != statusArr[1]: bot.sendMessage(chat_id=chat_id, text=statusArr[i%2]) print('Different') browser.refresh() time.sleep(1) i = i+1
|