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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
| import json import time
import requests from selenium import webdriver from selenium.webdriver.support.ui import Select
USER_ID =
USER_PASSWORD =
CARD_NO =
NAME =
BIRTH =
CARD_YEAR =
CARD_MONTH =
WEBHOOK =
def xpath_click(browser, element): element = browser.find_element("xpath", element) element.click()
def id_send(browser, element, key): element = browser.find_element("id", element) element.send_keys(key)
def name_send(browser, element, key): element = browser.find_element("name", element) element.send_keys(key)
def id_select(browser, element, key): element = browser.find_element("id", element) select = Select(element) select.select_by_value(key)
def get_price(browser): element = browser.find_element( "xpath", "/html/body/div[6]/div[1]/div/div/div/div/div[1]/div/div/div[1]/div/p/strong", ) return int(element.text[:-1].replace(",", ""))
def price_send(browser, PRICE): element = browser.find_element("id", "displayPayAmt") browser.execute_script("arguments[0].value = '';", element) element = browser.find_element("xpath", '//*[@id="displayPayAmt"]') element.send_keys(PRICE)
def login(browser): id_send(browser, "username-1-6", USER_ID) id_send(browser, "password-1", USER_PASSWORD) xpath_click( browser, "/html/body/div[1]/div/div/div[4]/div[1]/div/div[2]/div/div/div/div/section/div/button", ) xpath_click( browser, "/html/body/div[1]/div/div/div[4]/div[1]/div/div[2]/div/div/div/div/section/div/button", ) time.sleep(5)
def move(browser): browser.get("https://www.lguplus.com/mypage/payinfo?p=1") time.sleep(3) xpath_click( browser, "/html/body/div[1]/div/div/div[4]/div[1]/div/div[2]/div/div/div/div[2]/div[1]/div/div[3]/button[1]", ) time.sleep(8)
def info(browser, PRICE): id_send(browser, "cardNo", CARD_NO) name_send(browser, "cardCustName", NAME) name_send(browser, "cardCustbirth", BIRTH) id_select(browser, "selCardDate1", CARD_YEAR) id_select(browser, "selCardDate2", CARD_MONTH) price_send(browser, PRICE) price_send(browser, PRICE)
def send_discord_message(webhook_url, content): data = {"content": content} headers = {"Content-Type": "application/json"} response = requests.post(webhook_url, data=json.dumps(data), headers=headers) return response
if __name__ == "__main__": try: options = webdriver.ChromeOptions() options.add_argument("--headless") options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-gpu") options.add_argument( "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36" ) browser = webdriver.Chrome(options)
browser.get("https://www.lguplus.com/login/onid-login")
login(browser)
move(browser)
tmp = get_price(browser)
if tmp == 0 or tmp == 5999: send_discord_message(WEBHOOK, f":no_bell: [결제 :x:] 자동결제 금액:\t{tmp}원") exit() elif tmp > 5999 + 5999: PRICE = "5999" else: PRICE = str(tmp - 5999)
send_discord_message(WEBHOOK, f":bell: [결제 :o:] 결제 예정 금액:\t{PRICE}원") info(browser, PRICE)
xpath_click(browser, "/html/body/div[6]/div[1]/div/div/footer/button[2]") send_discord_message(WEBHOOK, f":bell: [결제 :o:] 결제 완료!:\t{PRICE}원") send_discord_message( WEBHOOK, f":bell: [결제 :o:] 결제 후 결제 예정 금액:\t{tmp - int(PRICE)}원" ) except Exception as e: send_discord_message( WEBHOOK, ":warning:" * 10 + "ERROR!!!" + ":warning:" * 10 + "\n" + "```\n" + str(e) + "\n```", )
|