from select import select
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support.ui import Select
import pandas as pd
import time
driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://mallbo.epost.go.kr')
time.sleep(5)
e = driver.find_element_by_xpath('//*[@id="id"]')
e.send_keys('jwhan311')
e = driver.find_element_by_xpath('//*[@id="pw"]')
e.send_keys('posa02144!')
e = driver.find_element_by_id('login_btn')
e.click()
time.sleep(1)
try:
da = Alert(driver)
da.accept()
except:
print('알람창없음')
time.sleep(1)
e = driver.find_element_by_xpath('//*[@id="M113"]/a')
e.click()
time.sleep(1)
e = driver.find_element_by_xpath('//*[@id="M2033"]/a')
e.click()
time.sleep(1)
e = driver.find_element_by_xpath('//*[@id="M2035"]/a')
e.click()
time.sleep(1)
select = Select(driver.find_element_by_xpath('//*[@id="search_exhibit_div"]'))
select.select_by_value('08')
time.sleep(1)
select = Select(driver.find_element_by_xpath('//*[@id="search_todaysale_stus_cd"]'))
select.select_by_value('01')
time.sleep(1)
df1 = pd.read_csv('./temp.csv',encoding='cp949')
print(len(df1))
time.sleep(1)
for i in range(len(df1)):
time.sleep(1)
e=driver.find_element_by_xpath('//*[@id="search_text"]')
e.clear()
e.send_keys(df1.iat[i,0])
time.sleep(1)
driver.find_element_by_xpath('//*[@id="search_btn"]').click()
time.sleep(1)
try:
e=driver.find_element_by_id('jqg_gridList_2')
e.click()
except:
try:
e=e=driver.find_element_by_id('jqg_gridList_1')
e.click()
except:
print('신청한거없음')
time.sleep(1)
driver.find_element_by_xpath('//*[@id="appr_btn"]').click()
time.sleep(1)
try:
da = Alert(driver)
da.accept()
except:
print('알람창없음')
time.sleep(1)
try:
da = Alert(driver)
da.accept()
except:
print('알람창없음')
time.sleep(1)
e=driver.find_element_by_xpath('//*[@id="search_text"]')
e.clear()
time.sleep(1)
driver.find_element_by_xpath('//*[@id="search_btn"]').click()
time.sleep(1)
select = Select(driver.find_element_by_xpath('//*[@id="rowList"]/select'))
select.select_by_value('100')
time.sleep(3)
isChanged = False
for i in range(100):
e= driver.find_element_by_xpath('//*[@id="jqg_gridList_'+str(i+1)+'"]')
if isChanged == True:
e.click()
try:
if driver.find_element_by_xpath('//*[@id="'+str(i+1)+'"]/td[5]').text != driver.find_element_by_xpath('//*[@id="'+str(i+2)+'"]/td[5]').text:
isChanged = True
except:
print('다체크함')
time.sleep(0.03)
if i ==20:
driver.execute_script("window.scrollTo(0,document.body.scrollHeight/3);")
if i ==68:
driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
time.sleep(1)
driver.execute_script("window.scrollTo(0,0);")
time.sleep(1)
select = Select(driver.find_element_by_xpath('//*[@id="todaysale_stus_cd"]'))
select.select_by_value('03')
time.sleep(1)
driver.find_element_by_xpath('//*[@id="appr_btn"]').click()
time.sleep(1)
time.sleep(1)
try:
da = Alert(driver)
da.accept()
except:
print('알람창없음')
time.sleep(1)
try:
da = Alert(driver)
da.accept()
except:
print('알람창없음')
time.sleep(100)