안녕하세요 문과생도 AI 수강중인 정민관입니다.
작년에 제가 필요한 업무 매크로를 의뢰하고 만들어서 사용중인데요 코드가 있는데 활용방법을 몰라서 그대로 쓰고있었습니다. gpters 활동하면서 이런 매크로를 더 다양하고 자유롭게 사용하고싶습니다.
gpt를 활용해서 텍스트 내용을 변경해서 활용한 내용을 소개드리겠습니다:)!
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager
import pickle
import os
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.chrome.options import Options
def start_driver():
driver = webdriver.Chrome()
return driver
def load_cookies(driver):
if os.path.exists('cookies.pkl'):
with open('cookies.pkl', 'rb') as file:
cookies, saved_domain = pickle.load(file)
driver.get(saved_domain)
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'body')))
for cookie in cookies:
driver.add_cookie(cookie)
driver.refresh()
def save_cookies(driver):
cookies = driver.get_cookies()
current_domain = driver.current_url
with open('cookies.pkl', 'wb') as file:
pickle.dump((cookies, current_domain), file)
def perform_actions(driver, name):
text_field = driver.find_element("name", "keyword")
# Clear the text field
text_field.clear()
# Enter the new text
text_field.send_keys(name)
text_field.send_keys(Keys.RETURN)
try:
element = WebDriverWait(driver, 10).until(
EC.text_to_be_present_in_element((By.XPATH, '//*[@id="mArticle"]/div[2]/div[3]/div/div/li[1]/a/div/strong/span'), name)
)
li_elements = driver.find_elements(By.CSS_SELECTOR, '.ReactVirtualized__Grid__innerScrollContainer li')
first_li = li_elements[0]
first_li.click()
except TimeoutException as e:
print("Timed out waiting for page to load")
return e
def perform_message(driver, message):
# Wait for the input field to become available
try:
input_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'chatWrite')))
except TimeoutException:
print("Timed out waiting for the input field to load")
return
input_field.send_keys(message)
input_field.send_keys('\n')
# input_field.send_keys(Keys.RETURN)
time.sleep(1)
# Close the current focused window
driver.execute_script("window.close();")
# Switch focus back to the main window
driver.switch_to.window(driver.window_handles[0])
def close_driver(driver):
driver.quit()
if __name__ == "__main__":
driver = start_driver()
if os.path.exists('cookies.pkl'):
load_cookies(driver)
else:
driver.get('https://center-pf.kakao.com/_ctSxjxj/chats')
# 로그인 과정 코드...
wait = WebDriverWait(driver, 120) # adjust this as per your needs
element = wait.until(EC.presence_of_element_located((By.ID, 'kakaoBody')))
save_cookies(driver)
perform_actions(driver, name='나리')
perform_message(driver, message=('1', '23', '2314'))
close_driver(driver)
main.py
import time
import tkinter as tk
import pandas as pd
from io import StringIO
import message
import logging
def get_data_from_clipboard():
# Create a tk instance
root = tk.Tk()
# Hide the tk window
root.withdraw()
# Get data from the clipboard
data = root.clipboard_get()
return data
def data_to_dataframe(data):
# Use StringIO to mimic a file
data_io = StringIO(data)
df = pd.read_csv(data_io, sep='\t', header=None)
return df
def preprocess_dataframe(df):
# Replace the 10th and 19th rows in df with the first row's values
df.iloc[9] = df.iloc[0].values
df.iloc[18] = df.iloc[0].values
# Split df into 3 DataFrames, each with 9 rows
df_split = [df[i:i+9] for i in range(0, df.shape[0], 9)]
return df_split
def split_dataframe(df_split):
sub_dfs = []
for df in df_split:
last_index = 0
max_index = 1
current_sub_dfs = []
for i in range(df.shape[1]):
if df.iloc[0, i] == '번호':
sub_df = df.iloc[:, last_index:i]
current_sub_dfs.append(sub_df)
last_index = i
max_index+=1
sub_df = df.iloc[:, last_index:]
current_sub_dfs.append(sub_df)
sub_dfs.append(current_sub_dfs)
return sub_dfs
def process_sub_dfs(sub_dfs):
# Set the first row of each sub DataFrame as the column header
for sub_df in sub_dfs:
for s_df in sub_df:
first_row = s_df.iloc[0].copy()
first_row = first_row.apply(lambda x: str(int(x)) if pd.notna(x) and isinstance(x, float) and x.is_integer() else str(x))
# Replace '보관함번호' with '번호'
first_row = first_row.replace('보관함번호', '번호')
s_df.columns = first_row
s_df.drop(s_df.index[0], inplace=True)
s_df.reset_index(drop=True, inplace=True)
def concat_sub_dfs(sub_dfs):
final_dfs = []
for sub_df in sub_dfs:
# Concatenate all DataFrames, ignoring the original index
final_df = pd.concat(sub_df, ignore_index=True)
final_dfs.append(final_df)
return final_dfs
def generate_data_dict(final_dfs):
# Create an empty dictionary
data_dict = {}
day_index = 0
for final_df in final_dfs:
# Iterate over each row in the DataFrame
for idx, row in final_df.iterrows():
# Check if the values in the '22' and '23' columns are not NaN
if pd.notna(row['22']):
# Use the values in the '22' columns as keys,
# but only up to the first '/'
key_22 = str(row['22']).split('/')[0]
# Use the values in the '번호' and '비밀번호' columns as values
values = (row['번호'], '22', row['비밀번호'])
# Add this key-value pair to the dictionary
if key_22 in data_dict:
data_dict[key_22].append(values)
else:
data_dict[key_22] = [values]
if pd.notna(row['23']):
# Use the values in the '23' columns as keys,
# but only up to the first '/'
key_23 = str(row['23']).split('/')[0]
# Use the values in the '번호' and '비밀번호' columns as values
values = (row['번호'], '23', row['비밀번호'])
# Add this key-value pair to the dictionary
if key_23 in data_dict:
data_dict[key_23].append(values)
else:
data_dict[key_23] = [values]
for key in data_dict:
unique_tuple = []
temp_set = set()
for item in data_dict[key]:
if item[0:2] not in temp_set:
unique_tuple.append(item)
temp_set.add(item[0:2])
data_dict[key] = unique_tuple
return data_dict
def print_data_dict(data_dict):
print(data_dict)
def dummy_dict():
return {'홍길동 ': [('3', '23', '9239')]}
def make_message(device_info):
number, device_name, password = device_info
number, device_name, password = device_info
number = int(number)
if number >= 37:
if device_name == '23':
extra_message = f"""
보관함 번호는 {number}, 비번은 {password} 입니다. 필요한 전달 메시지
""".rstrip()
elif device_name == '22':
extra_message = f"""
보관함 번호는 {number}, 비번은 {password} 입니다. 필요한 전달 메시지
""".rstrip()
else:
raise ValueError("Invalid device name. Expected '22' or '23'.".rstrip())
else:
if device_name == '23':
extra_message = f"""
보관함 번호는 {number}, 비번은 {password} 입니다. 필요한 전달 메시지
""".rstrip()
elif device_name == '22':
extra_message = f"""
보관함 번호는 {number}, 비번은 {password} 입니다. 필요한 전달 메시지
""".rstrip()
else:
raise ValueError("Invalid device name. Expected '22' or '23'.".rstrip())
final_message = extra_message
# final_message = final_message.replace('\n', ' ')
return final_message.rstrip()
if __name__ == "__main__":
# Clear the existing log file
with open('error.log', 'w'):
pass
# Logging setup
logging.basicConfig(filename='error.log', level=logging.ERROR)
data = get_data_from_clipboard()
df = data_to_dataframe(data)
df_split = preprocess_dataframe(df)
sub_dfs = split_dataframe(df_split)
process_sub_dfs(sub_dfs)
final_dfs = concat_sub_dfs(sub_dfs)
data_dict = generate_data_dict(final_dfs)
# data_dict = dummy_dict()
print_data_dict(data_dict)
driver = message.start_driver()
driver.get('https://center-pf.kakao.com/_ctSxjxj/chats')
# 로그인 과정 코드...
wait = message.WebDriverWait(driver, 120) # adjust this as per your needs
element = wait.until(message.EC.presence_of_element_located((message.By.ID, 'kakaoBody')))
time.sleep(10)
for key in data_dict.keys():
# Perform the action for the key
exception = message.perform_actions(driver, name=key.rstrip())
if exception:
logging.error(f"메세지창 오픈 에러 : {key}")
print("New message window did not open for key:", key)
else:
# If a new window has opened
if len(driver.window_handles) > 1:
# Switch focus to the new window
driver.switch_to.window(driver.window_handles[1])
# If the new window opened successfully, continue with the operations
# 현재 키에 해당하는 값을 리스트로 받아옴
value_list = data_dict[key]
# 리스트 내부의 튜플들을 순회
for value_tuple in value_list:
print("Value Tuple:", value_tuple)
message.perform_message(driver, message=make_message(value_tuple))
message.close_driver(driver)
해당 파일을 넣고 gpt에 질문했습니다.
해당 코드를 읽고 한줄씩 수정해줘.
main.py
이 스크립트는 클립보드에서 데이터를 읽어와서 데이터프레임으로 변환하고, 특정 형식의 메시지를 생성하여 카카오톡 채팅방에 자동으로 전송하는 과정을 자동화합니다. 각 단계를 자세히 설명하겠습니다.
라이브러리 임포트:
time, tkinter, pandas, io.StringIO는 데이터 처리와 시간 지연, GUI 인터페이스 관리에 사용됩니다.
message와 logging은 로깅과 사용자 정의 모듈(여기서는 메시지 전송과 관련된 함수를 포함할 것으로 추정됨)을 위해 임포트됩니다.
get_data_from_clipboard 함수:
클립보드의 내용을 읽어서 반환합니다. tkinter를 사용해 클립보드에서 데이터를 가져옵니다.
data_to_dataframe 함수:
클립보드 데이터를 StringIO를 통해 파일처럼 다루어 pandas 데이터프레임으로 변환합니다. 데이터는 탭(\t)으로 구분되어 있다고 가정합니다.
preprocess_dataframe 함수:
데이터프레임을 전처리하여 10번째와 19번째 행을 첫 번째 행의 값으로 대체하고, 데이터프레임을 9행씩 분할하여 리스트로 반환합니다.
split_dataframe 함수:
분할된 데이터프레임을 기반으로 추가 분할을 수행하여 서브 데이터프레임 리스트를 생성합니다. 여기서 '번호' 열을 기준으로 분할 기준을 정합니다.
process_sub_dfs 함수:
각 서브 데이터프레임의 첫 번째 행을 열 이름으로 설정하고, '보관함번호'를 '번호'로 변경합니다. 이후 첫 번째 행을 삭제하고 인덱스를 재설정합니다.
concat_sub_dfs 함수:
처리된 서브 데이터프레임들을 하나의 데이터프레임으로 결합합니다.
generate_data_dict 함수:
최종 데이터프레임을 기반으로 특정 열의 값(여기서는 '22'와 '23')을 키로 하고, 관련 정보를 값으로 하는 사전을 생성합니다.
print_data_dict 함수:
생성된 데이터 사전을 출력합니다.
dummy_dict 함수:
더미 데이터 사전을 반환합니다. 이는 테스트 또는 예시 목적으로 사용될 수 있습니다.
make_message 함수:
주어진 정보(장치 정보)를 기반으로 메시지를 생성합니다. 메시지 형식은 주어진 장치 번호와 타입에 따라 다릅니다.
메인 실행 블록:
로깅 설정을 초기화하고, 클립보드에서 데이터를 가져와 데이터프레임으로 변환합니다. 데이터를 처리하고, 최종 데이터 사전을 생성한 후, 카카오톡 채팅방에 접속하여 각 키(사용자 이름)에 대해 메시지를 전송합니다. 메시지 전송 과정에서 예외가 발생하면 로그 파일에 기록됩니다.
이 코드는 특정 형식의 데이터를 처리하고, 이를 바탕으로 사용자에게 맞춤 메시지를 자동으로 전송하는 자동화 스크립트의 예시입니다.
message.py 답변
물론이죠, 단계별로 코드를 설명드리겠습니다.
라이브러리 임포트:
selenium은 웹 브라우저를 자동으로 조작하기 위한 라이브러리입니다.
pickle은 파이썬 객체를 파일로 저장하고 불러오는 데 사용됩니다.
os는 운영 체제와 상호 작용하는 데 사용되며, 여기서는 파일 경로 및 존재 여부를 확인하는 데 사용됩니다.
time은 스크립트 실행 중에 대기 시간을 관리하는데 사용됩니다.
start_driver 함수:
이 함수는 새로운 Chrome 웹 드라이버 인스턴스를 시작합니다.
load_cookies 함수:
이 함수는 cookies.pkl 파일이 존재하는 경우, 이 파일로부터 쿠키와 저장된 도메인을 불러옵니다.
드라이버가 해당 도메인으로 이동한 후, 저장된 쿠키들을 웹 브라우저 세션에 추가합니다.
save_cookies 함수:
현재 드라이버 세션의 쿠키들을 가져와서 cookies.pkl 파일에 저장합니다. 이를 통해 나중에 세션을 재개할 수 있습니다.
perform_actions 함수:
이 함수는 특정 요소를 찾아 텍스트를 입력하고, 검색 결과에서 첫 번째 항목을 클릭하는 일련의 작업을 수행합니다.
perform_message 함수:
이 함수는 특정 입력 필드에 메시지를 입력하고, 메시지를 보낸 후 현재 포커스된 창을 닫고 메인 창으로 다시 포커스를 전환합니다.
close_driver 함수:
이 함수는 드라이버 인스턴스를 종료하고, 브라우저 창을 닫습니다.
메인 실행 블록:
드라이버를 시작하고, 쿠키가 있는 경우 쿠키를 불러옵니다. 그렇지 않은 경우 사용자가 로그인할 수 있도록 특정 URL로 이동하고 쿠키를 저장합니다.
perform_actions 함수를 호출하여 특정 작업을 수행하고, perform_message 함수를 통해 메시지를 보냅니다.
마지막으로 드라이버를 종료합니다.
이 코드는 웹 자동화 및 웹 스크래핑에 사용됩니다. Selenium을 사용하여 웹 브라우저를 제어하고, 특정 작업을 자동으로 수행합니다.
간단하게 입력 메시지를 수정해서 실행해보고 싶었습니다.
Q: 해당 파일에 대한 테스트실행 방법을 알려줘
파일 두 개가 업로드되었습니다. 각 파일의 내용을 확인하고, 테스트 실행 방법에 대해 안내해드리겠습니다. 먼저 message.py 파일의 내용을 살펴보겠습니다.
message.py 파일은 Selenium을 사용해 웹 브라우저를 자동화하는 스크립트입니다. 이 스크립트는 다음 기능을 수행합니다:
웹 드라이버 시작: Chrome 웹 드라이버를 시작합니다.
쿠키 로드: 이전 세션의 쿠키를 로드하여 로그인 상태 등을 유지합니다.
쿠키 저장: 현재 세션의 쿠키를 저장합니다.
행동 수행: 웹 페이지에서 특정 행동(예: 텍스트 입력, 버튼 클릭)을 자동으로 수행합니다.
메시지 전송: 지정된 메시지를 웹 페이지의 입력 필드에 전송합니다.
드라이버 종료: 웹 드라이버를 종료하고 브라우저를 닫습니다.
스크립트는 주로 특정 웹 사이트(예: 카카오 채팅 센터)에 자동으로 메시지를 보내는 데 사용됩니다. 스크립트 실행에 필요한 주요 단계는 다음과 같습니다:
필요한 라이브러리 설치(예: selenium, webdriver_manager)
ChromeDriver 설치 및 설정
스크립트 내의 driver.get('https://center-pf.kakao.com/_ctSxjxj/chats') 부분에 원하는 웹 페이지 주소 설정
로그인 과정 코드 작성(쿠키 파일이 없는 경우 필요)
스크립트를 실행하여 자동화된 테스트 수행
이제 main.py 파일의 내용을 확인해 보겠습니다.
main.py 파일은 데이터 처리와 웹 자동화 작업을 함께 수행하는 복잡한 스크립트입니다. 이 스크립트의 주요 기능은 다음과 같습니다:
클립보드에서 데이터 가져오기: 사용자의 클립보드에서 데이터를 가져옵니다.
데이터를 데이터프레임으로 변환: 가져온 데이터를 pandas 데이터프레임으로 변환합니다.
데이터 전처리: 데이터프레임을 필요에 맞게 전처리합니다.
데이터프레임 분할: 전처리된 데이터프레임을 여러 개의 서브 데이터프레임으로 분할합니다.
서브 데이터프레임 처리: 각 서브 데이터프레임에 대한 처리를 수행합니다.
서브 데이터프레임 결합: 처리된 서브 데이터프레임들을 하나의 최종 데이터프레임으로 결합합니다.
데이터 딕셔너리 생성: 최종 데이터프레임에서 데이터 딕셔너리를 생성합니다.
웹 자동화 작업 실행: message.py에 정의된 함수를 사용하여 웹 페이지에서 특정 작업을 자동으로 수행합니다.
스크립트는 tkinter를 사용하여 클립보드 데이터를 가져오고, pandas를 사용하여 데이터 처리를 수행한 후, Selenium을 사용해 웹 자동화 작업을 실행합니다. 이 스크립트를 실행하기 전에 필요한 라이브러리(pandas, selenium, tkinter)가 설치되어 있어야 합니다.
테스트 실행 방법은 다음과 같습니다:
필요한 Python 라이브러리 설치: pandas, selenium, tkinter 등 필요한 라이브러리가 설치되어 있지 않다면 설치합니다.
main.py 실행 전에 클립보드에 필요한 데이터를 복사합니다.
main.py 스크립트를 실행합니다. 스크립트는 클립보드에서 데이터를 가져와 처리한 후, message.py 스크립트를 사용하여 웹 자동화 작업을 수행합니다.
이 과정은 데이터 처리와 웹 자동화를 결합한 복잡한 자동화 작업을 수행합니다. 실행하기 전에 모든 필요한 설정(예: 로그인 정보, 타겟 웹사이트 주소)이 스크립트 내에 올바르게 구성되어 있는지 확인해야 합니다.
두 파일(message.py와 main.py)을 실행하는 과정은 각각의 목적과 기능에 따라 달라질 수 있습니다. message.py는 웹 자동화를 위한 Selenium 기반 스크립트이며, main.py는 데이터 처리와 message.py를 이용한 자동화 작업을 함께 수행하는 스크립트입니다. 실행 방법은 다음과 같습니다.
1. 필요한 환경 준비하기
Python 설치: Python이 시스템에 설치되어 있어야 합니다. Python 설치는 Python 공식 웹사이트에서 할 수 있습니다.
필요한 라이브러리 설치: selenium, pandas, tkinter 등 필요한 라이브러리가 설치되어 있지 않다면 설치해야 합니다. 이는 다음 명령어를 통해 설치할 수 있습니다:
bashCopy codepip install selenium pandas
tkinter는 대부분의 Python 설치에 포함되어 있으므로 별도 설치가 필요하지 않습니다. 만약 설치가 필요한 경우에는 이전 답변을 참조하세요.
WebDriver 설치: selenium을 사용하기 위해, 사용하는 브라우저에 맞는 WebDriver가 필요합니다. 예를 들어, Chrome을 사용한다면 ChromeDriver를 설치해야 합니다. WebDriver는 브라우저의 공식 웹사이트에서 다운로드할 수 있으며, webdriver-manager 패키지를 사용하는 것도 한 방법입니다.
2. message.py 실행하기
message.py는 독립적으로 실행할 수 있으며, 특정 웹 사이트에서 로그인하고 메시지를 전송하는 등의 작업을 자동화합니다.
이 파일을 실행하기 전에, 필요한 모든 설정(예: 타겟 URL, 로그인 정보 등)이 코드 내에 올바르게 구성되어 있는지 확인하세요.
파일을 실행하는 방법은 터미널 또는 커맨드 라인에서 다음 명령어를 입력하는 것입니다:
bashCopy codepython message.py
3. main.py 실행하기
main.py는 message.py를 포함해 데이터 처리와 웹 자동화 작업을 수행합니다.
실행하기 전에, 클립보드에 필요한 데이터가 복사되어 있는지 확인하세요. main.py는 클립보드에서 데이터를 읽어와서 처리합니다.
main.py도 마찬가지로 터미널 또는 커맨드 라인에서 다음과 같이 실행할 수 있습니다:
bashCopy codepython main.py
주의사항
스크립트를 실행하기 전에 코드 내의 주석 또는 설정 부분을 확인하여, 환경에 맞게 필요한 변경을 해야 할 수 있습니다.
message.py와 main.py는 서로 연관되어 있으므로, main.py를 실행하기 위해서는 message.py도 올바르게 설정되어 있어야 합니다.
스크립트가 예상대로 작동하지 않는다면, 에러 메시지를 확인하고 문제를 해결해야 합니다. 필요한 경우, 로그인 정보나 WebDriver의 경로 설정 등을 확인하세요.
에러코드가 발생했고 해결방법을 물어보았습니다.
에러내용.
E:\폴더\pycharm\venv\Scripts\python.exe E:\폴더\pycharm\main.py
{'정민관': [('1', '23', '4357')]}
Traceback (most recent call last):
File "E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
File "E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 106, in driver_location
output = self.run(args)
File "E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 154, in run
raise WebDriverException(f"Unsuccessful command executed: {command}.\n{result}{stderr}")
selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --language-binding python --output json.
{'code': 69, 'message': 'Driver unavailable: Driver path: ', 'driver_path': '', 'browser_path': ''}
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\폴더\pycharm\main.py", line 195, in <module>
driver = message.start_driver()
File "E:\폴더\pycharm\message.py", line 15, in start_driver
driver = webdriver.Chrome()
File "E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
super().__init__(
File "E:\폴더\pycharm\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 49, in __init__
self.service.path = DriverFinder.get_path(self.service, options)
File "E:\스냅슛\pycharm\venv\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 41, in get_path
raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
Process finished with exit code 1
해결답변
코드 분석에 따르면, start_driver 함수에서 executable_path 인자를 사용하여 ChromeDriver의 경로를 지정하고 있습니다. 이는 기존 문제에서 지적된 오류를 해결하기 위한 올바른 접근 방식입니다. 그러나 TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path' 오류가 발생했을 때, 이는 일반적으로 Selenium의 특정 버전에서 발생할 수 있는 문제입니다. 최신 버전의 Selenium WebDriver에서는 Service 객체를 사용하여 WebDriver의 경로를 지정하는 새로운 방식을 제공합니다. 코드를 업데이트하여 이 새로운 방식을 사용해 보겠습니다:
python
Copy code
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
# 나머지 필요한 import 문을 여기에 추가합니다.
def start_driver():
# ChromeDriver의 경로를 Service 객체를 통해 지정합니다.
service = Service(executable_path=r'E:\스냅슛\pycharm\chromedriver.exe')
driver = webdriver.Chrome(service=service)
return driver
# 나머지 함수들...
if __name__ == "__main__":
driver = start_driver()
# 로그인 및 쿠키 관련 코드...
# perform_actions, perform_message 함수 호출 등 나머지 로직을 실행합니다.
이 변경은 Selenium 4 이상 버전에서 webdriver.Chrome() 호출 시 executable_path 대신 Service 객체를 사용하는 새로운 방식을 따릅니다. 이 방식은 executable_path 인자를 직접 전달하는 대신, Service 클래스의 인스턴스를 통해 ChromeDriver의 경로를 지정합니다.
변경 후 코드를 실행하기 전에, 사용 중인 Selenium 패키지가 최신 버전인지 확인하고 필요한 경우 업데이트하세요:
bash
Copy code
pip install -U selenium
이렇게 하면, TypeError 오류를 해결하고 Chrome WebDriver를 성공적으로 초기화할 수 있습니다.
해결하고 이제는 pyinstall 활용해서 실행파일로 만드는걸 시도해보고 있습니다.
gpters가 끝날때는 이렇게 제가 필요한 매크로 프로그램을 추가로 만들어보고싶습니다! 모두 화이팅입니다 감사합니다.
#문과생도AI9기