201 lines
5.0 KiB
Plaintext
201 lines
5.0 KiB
Plaintext
#################################################################################################
|
|
# 배치 start #####################################################################################
|
|
from tkinter import *
|
|
|
|
# 배치 place ###
|
|
# win = Tk()
|
|
# win.geometry("500x300")
|
|
# win.title("pack")
|
|
# win.option_add("*Font","궁서 20")
|
|
#
|
|
# # 배치 grid ###
|
|
# btn = Button(win)
|
|
# btn.config(text='new')
|
|
# btn.place(x=10, y=10)
|
|
#
|
|
# btn2 = Button(win)
|
|
# btn2.config(text='new2')
|
|
# btn2.place(x=100, y=100)
|
|
#
|
|
#
|
|
# btn3 = Button(win)
|
|
# btn3.config(text='new')
|
|
# btn3.place(relx=0.5, rely=0.5)
|
|
#
|
|
# btn4 = Button(win)
|
|
# btn4.config(text='new2')
|
|
# btn4.place(x=0.8, rely=0.8)
|
|
# 배치 place ###
|
|
|
|
# 배치 grid ###
|
|
# btn_list = []
|
|
# col_num =4
|
|
# row_num =3
|
|
#
|
|
# for j in range(0,row_num):
|
|
# for i in range(0,col_num):
|
|
# btn = Button(win)
|
|
# btn.config(text='({},{})'.format(i,j), padx=10)
|
|
# btn.grid(column=i, row=j, padx=10, pady=10)
|
|
# btn_list.append(btn)
|
|
#
|
|
# btn = Button(win)
|
|
# btn.config(text='new',width=5, height=4)
|
|
# btn.grid(column=3, row=0, rowspan=2)
|
|
#
|
|
# btn2 = Button(win)
|
|
# btn2.config(text='new2')
|
|
# btn2.grid(column=1, row=2, columnspan=2)
|
|
# 배치 grid ###
|
|
|
|
|
|
# 배치 pack ###
|
|
# ent=Entry(win)
|
|
# ent.pack(side='top')
|
|
#
|
|
# btn = Button(win)
|
|
# btn.config(text='button')
|
|
# def aa():
|
|
# btn.pack(pady=ent.get())
|
|
#
|
|
# btn.config(command=aa)
|
|
# btn.pack()
|
|
#
|
|
# btn2 = Button(win)
|
|
# btn2.config(text='temp')
|
|
# btn2.pack()
|
|
# 배치 pack ###
|
|
|
|
win.mainloop()
|
|
# 배치 end #####################################################################################
|
|
|
|
|
|
# 버튼 입력폼 연동 크롤링 start ####################################################################
|
|
|
|
from tkinter import *
|
|
from datetime import datetime
|
|
from bs4 import BeautifulSoup
|
|
import requests
|
|
|
|
win=Tk()
|
|
win.geometry("600x100")
|
|
win.title('테스트 GUI')
|
|
win.option_add("*Font","궁서 20")
|
|
def lotto_p():
|
|
n=ent.get()
|
|
url = "https://dhlottery.co.kr/gameResult.do?method=byWin&drwNo={}".format(n)
|
|
req = requests.get(url)
|
|
soup = BeautifulSoup(req.text, "html.parser")
|
|
txt=soup.find("div", attrs={"class","win_result"}).get_text()
|
|
title = txt.split("\n")[1:3]
|
|
numlist = txt.split("\n")[7:13]
|
|
bonus = txt.split("\n")[-4]
|
|
print(title)
|
|
print(numlist)
|
|
print(bonus)
|
|
|
|
|
|
btn = Button(win)
|
|
btn.config(text='로또당첨번호 확인')
|
|
#btn.config(width=10, height=1)
|
|
btn.config(command=lotto_p)
|
|
btn.pack()
|
|
|
|
ent=Entry(win)
|
|
ent.pack()
|
|
|
|
|
|
win.mainloop()
|
|
|
|
# 버튼 입력폼 연동 크롤링 end ####################################################################
|
|
|
|
# 로그인폼 브라우저 데이터 전송 자동로그인 start#####################################################
|
|
from tkinter import *
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.chrome.service import Service as ChromeService
|
|
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
|
from webdriver_manager.chrome import ChromeDriverManager
|
|
|
|
# id pw log.login
|
|
|
|
win=Tk()
|
|
win.geometry("400x300")
|
|
win.title('다음로그인')
|
|
win.option_add("*Font","궁서 20")
|
|
btn = Button(win)
|
|
|
|
#로고
|
|
lab_logo = Label(win)
|
|
img = PhotoImage(file="./google.png", master=win)
|
|
img = img.subsample(2)
|
|
lab_logo.config(image=img)
|
|
lab_logo.pack()
|
|
|
|
#id 라벨
|
|
lab1 = Label(win)
|
|
lab1.config(text="아이디")
|
|
lab1.pack()
|
|
|
|
#pw 입력창
|
|
ent1 = Entry(win)
|
|
ent1.insert(0,"test@test.com")
|
|
def clear(event):
|
|
if ent1.get() == "test@test.com":
|
|
ent1.delete(0, len(ent1.get()))
|
|
|
|
ent1.bind("<Button-1>", clear)
|
|
ent1.pack()
|
|
|
|
#pw 라벨
|
|
lab2 = Label(win)
|
|
lab2.config(text="비밀번호")
|
|
lab2.pack()
|
|
|
|
#pw 입력창
|
|
ent2 = Entry(win)
|
|
ent2.config(show="*")
|
|
ent2.pack()
|
|
|
|
#로그인버튼
|
|
btn = Button(win)
|
|
btn.config(text='로그인')
|
|
def login():
|
|
my_id = ent1.get()
|
|
my_pass = ent2.get()
|
|
|
|
options = ChromeOptions()
|
|
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
|
|
options.add_argument('user-agent=' + user_agent)
|
|
options.add_argument("lang=ko_KR")
|
|
options.add_argument('window-size=1920x1080')
|
|
options.add_argument("disable-gpu")
|
|
options.add_experimental_option("detach", True)
|
|
|
|
service = ChromeService(executable_path=ChromeDriverManager().install())
|
|
driver = webdriver.Chrome(service=service, options=options)
|
|
url = "https://accounts.kakao.com/login/?continue=https%3A%2F%2Flogins.daum.net%2Faccounts%2Fksso.do%3Frescue%3Dtrue%26url%3Dhttps%253A%252F%252Fwww.daum.net#login"
|
|
driver.get(url)
|
|
driver.implicitly_wait(5)
|
|
|
|
xpath1 = "//input[@name='loginId']"
|
|
driver.find_element(By.XPATH, xpath1).send_keys(my_id)
|
|
driver.implicitly_wait(5)
|
|
xpath2 = "//input[@name='password']"
|
|
driver.find_element(By.XPATH, xpath2).send_keys(my_pass)
|
|
driver.implicitly_wait(5)
|
|
xpath3 = "//button[@class='btn_g highlight submit']"
|
|
driver.find_element(By.XPATH, xpath3).click()
|
|
lab3.config(text='[메세지]로그인성공')
|
|
|
|
btn.config(command=login)
|
|
btn.pack()
|
|
|
|
#메세지라벨
|
|
lab3 = Label(win)
|
|
lab3.pack()
|
|
|
|
win.mainloop()
|
|
|
|
# 로그인폼 브라우저 데이터 전송 자동로그인 end#######################################################
|