{"id":26833404,"url":"https://github.com/mr-won/tk_login","last_synced_at":"2025-03-30T15:28:54.795Z","repository":{"id":138423043,"uuid":"453612472","full_name":"mr-won/Tk_Login","owner":"mr-won","description":"tkinter 라이브러리와 Python 언어를 사용해서 다음, 카카오 자동 로그인 프로그램 만들기","archived":false,"fork":false,"pushed_at":"2025-03-08T00:57:31.000Z","size":6066,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T02:27:15.361Z","etag":null,"topics":["python","tkinter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mr-won.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-30T07:10:42.000Z","updated_at":"2025-03-08T00:58:08.000Z","dependencies_parsed_at":"2025-03-18T02:37:22.869Z","dependency_job_id":null,"html_url":"https://github.com/mr-won/Tk_Login","commit_stats":null,"previous_names":["wonttan/tk_login","wonchihyeon/tk_login","chihyunwon/tk_login","mr-won/tk_login","chihyeonwon/tk_login"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_Login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_Login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_Login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_Login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-won","download_url":"https://codeload.github.com/mr-won/Tk_Login/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246337861,"owners_count":20761282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","tkinter"],"created_at":"2025-03-30T15:28:54.362Z","updated_at":"2025-03-30T15:28:54.788Z","avatar_url":"https://github.com/mr-won.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tk_Login\ntkinter 라이브러리와 Python 언어를 사용해서 다음, 카카오 자동 로그인 프로그램 만들기   \n\n## 25년 업무용 프로그램 개발 시작\n\n위젯에 대한 설명   \n사용자가 프로그램을 쓰기 쉽게 라벨을 붙임으로써 다른 위젯이 어떤 것인지 설명할 수 있습니다.   \n프로그램이 어떤 상태인지에 대해서도 설명할 수 있습니다.   \n## 창 생성\n\n창을 생성하고 창의 제목, 크기, 세부옵션을 설정하고 실행합니다.   \n```python\nfrom tkinter import *\nwin = Tk()\nwin.title(\"Daum Log-in\")\nwin.geometry(\"400x300\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\nwin.mainloop()\n```\n  \n## 다음로고 이미지 추가   \n\n이미지 추가를 위해서 필요한 모듈을 import 한다.   \n```python\nfrom PIL import ImageTk\n```\n\n다음로고를 넣을 라벨을 생성하고 img 객체를 생성하고 image의 값으로 준다.   \n```python  \n# 다음 로고\nlab_d = Label(win)\nimg = ImageTk.PhotoImage(file='image.png', master=win)\nlab_d.config(image=img)\nlab_d.pack()  \n```\n\n## ID,PW 라벨과 ID, PW 입력창 생성   \n\nLabel 함수를 사용해서 lab1 변수 이름의 라벨을 만들어주고 라벨을 배치합니다.   \n```python\n# id 입력창\nent1 = Entry(win)\nent1.insert(0, \"temp@temp.com\")\n\n\ndef clear(event):\n    if ent1.get() == \"temp@temp.com\":\n        ent1.delete(0, len(ent1.get()))\n\n\nent1.bind(\"\u003cButton-1\u003e\", clear)\nent1.pack()\n\n# pw 라벨\nlab2 = Label(win)\nlab2.config(text=\"Password\")\nlab2.pack()\n\n# pw 입력창\nent2 = Entry(win)\nent2.config(show=\"*\")\nent2.pack()\n```\n  \n#### 아이디 입력창을 클릭하기 전   \n![login](https://user-images.githubusercontent.com/58906858/151758951-270a8094-ef1d-47bf-a8d6-a28ca0bbae6e.png)\n#### 아이디 입력창을 클릭한 후 기본문자열이 삭제됨을 알 수 있다.   \n![login_delete](https://user-images.githubusercontent.com/58906858/151759115-bb726b38-6e62-4414-878c-b177ce19d488.png)\n  \n\n  \n  \n  \n  \nid 입력창은 bind함수로 좌클릭(Button-1)이 되었을 때만 clear함수를 실행하도록 구현하고 clear함수는 기본이메일형식일 때 좌클릭이 되면 기본이메일 문자열의 길이만큼 삭제하도록 구현한다.   \n\npw 입력창은 show 옵션으로 \"*\"을 줘서 입력하는 문자가 모두 *로 보이도록 구현한다.   \n  \n## 로그인 버튼 구현   \n  \n로그인 버튼 구현은 크롬브라우저의 버전과 같은 크롬드라이버를 다운로드하여 사용한다. 필요한 모듈을 import한다.   \n```python\nfrom selenium import webdriver\nimport time\n```\n\n버튼 구현 최종 코드는 다음과 같다.   \n```\nbtn = Button(win)\nbtn.config(text=\"로그인\")\n\ndef login():\n    options = webdriver.ChromeOptions()\n    options.add_experimental_option(\"excludeSwitches\", [\"enable-logging\"])\n    driver = webdriver.Chrome(options=options)\n    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%252F\"\n    driver.get(url)\n    time.sleep(5)  # 5초동안 대기합니다.\n    xpath1 = \"//input[@name='email']\"\n    driver.find_element(xpath1).send_keys(ent1.get())\n    xpath2 = \"//input[@name='password']\"\n    driver.find_element(xpath2).send_keys(ent2.get())\n    xpath3 = \"//button[@class='btn_g btn_confirm submit']\"\n    driver.find_element(xpath3).click()\n    lab3.config(text=\"[메시지] 로그인 성공\")\n\n\nbtn.config(command=login)\nbtn.pack()\n```\nlogin 함수에 대한 설명   \n\n5:7행 다운로드한 크롬드라이버를 현재 파일과 동일한 위치에 두고 옵션을 설정한다.       \n8행 다음카카오 로그인 페이지의 url을 url 변수에 넣고   \n9행 url 변수를 driver의 get함수에 넣어준다.   \n10행 불러올 때 로딩 대기시간을 주지않으면 오류가 발생하므로 5초의 대기시간을 준다.   \n11행 xpath1 변수에 id 입력창을 크롤링해서 저장한다.   \n12행 driver의 find_element함수로 xpath1을 주고 send_keys 함수로 id 입력창에서 입력한 문자를 받아와서 입력한다.   \n13행 xpath2 변수에 pw 입력창을 크롤링해서 저장한다.   \n14행 driver의 find_element함수로 xpath1을 주고 send_keys 함수로 pw 입력창에서 입력한 문자를 받아와서 입력한다.   \n15행 xpath3 변수에 로그인 버튼을 크롤링해서 저장한다.   \n16행 로그인 버튼을 눌렀을 때 클릭이 발생하도록 설정한다.   \n17행 lab3에 로그인 성공을 출력한다.   \n\n20행에서 로그인버튼을 클릭하면 생성한 로그인 함수를 실행하도록 설정한다.   \n  \n## 최종 코드와 프로그램 실행 화면   \n  \n최종 코드는 다음과 같습니다.   \n```python\nfrom tkinter import *\nfrom PIL import ImageTk\nfrom selenium import webdriver\nimport time\n\nwin = Tk()\nwin.title(\"Daum Log-in\")\nwin.geometry(\"400x600\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\n# 다음 로고\nlab_d = Label(win)\nimg = ImageTk.PhotoImage(file='image.png', master=win)\nlab_d.config(image=img)\nlab_d.pack()\n# id 라벨\nlab1 = Label(win)\nlab1.config(text=\"ID\")\nlab1.pack()\n\n# id 입력창\nent1 = Entry(win)\nent1.insert(0, \"temp@temp.com\")\n\n\ndef clear(event):\n    if ent1.get() == \"temp@temp.com\":\n        ent1.delete(0, len(ent1.get()))\n\n\nent1.bind(\"\u003cButton-1\u003e\", clear)\nent1.pack()\n\n# pw 라벨\nlab2 = Label(win)\nlab2.config(text=\"Password\")\nlab2.pack()\n\n# pw 입력창\nent2 = Entry(win)\nent2.config(show=\"*\")\nent2.pack()\n\n# 로그인 버튼\nbtn = Button(win)\nbtn.config(text=\"로그인\")\n\n\ndef login():\n    options = webdriver.ChromeOptions()\n    options.add_experimental_option(\"excludeSwitches\", [\"enable-logging\"])\n    driver = webdriver.Chrome(options=options)\n    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%252F\"\n    driver.get(url)\n    time.sleep(5)  # 5초동안 대기합니다.\n    xpath1 = \"//input[@name='email']\"\n    driver.find_element(xpath1).send_keys(ent1.get())\n    xpath2 = \"//input[@name='password']\"\n    driver.find_element(xpath2).send_keys(ent2.get())\n    xpath3 = \"//button[@class='btn_g btn_confirm submit']\"\n    driver.find_element(xpath3).click()\n    lab3.config(text=\"[메시지] 로그인 성공\")\n\n\nbtn.config(command=login)\nbtn.pack()\n\n# 메시지 라벨\nlab3 = Label(win)\nlab3.pack()\n\nwin.mainloop()\n```\n\n#### 프로그램 초기화면은 다음과 같습니다.   \n![login](https://user-images.githubusercontent.com/58906858/151758951-270a8094-ef1d-47bf-a8d6-a28ca0bbae6e.png)\n\n#### 아이디와 비번을 입력하고 로그인버튼을 누르면 다음과 같이 다음 카카오 로그인 창이 열리는데    \n![chrome](https://user-images.githubusercontent.com/58906858/151759564-23be583e-e5f9-4ca6-8f55-316393d9589f.png)  \n  \n*2022-01-31 현재 웹 보안 정책으로 크롤링이 정상적으로 작동되지 않음을 확인하였습니다. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Ftk_login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-won%2Ftk_login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Ftk_login/lists"}