문과생도 AI 3주차, 과제

  1. 네이버에 들어가서 ‘크루즈’를 검색하는 코드입니다.
    import os

    from selenium import webdriver

    from selenium.webdriver.chrome.options import Options

    from selenium.webdriver.common.by import By

    from selenium.webdriver.support.ui import WebDriverWait

    from selenium.webdriver.support import expected_conditions as EC

    import time


    # Get the current working directorycurrent_dir = os.getcwd()
    # Set the user data directory path relative to the current directoryuser_data_dir = os.path.join(current_dir, "user_data", "JG")
    options = Options()options.add_argument(f"user-data-dir={user_data_dir}")options.add_argument("disable-blink-features=AutomationControlled")options.add_experimental_option("detach", True)options.add_experimental_option("excludeSwitches", ["enable-logging"])
    # Chrome 드라이버 초기화driver = webdriver.Chrome(options=options)driver.maximize_window()
    # 네이버 홈페이지로 이동driver.get("https://www.naver.com")
    # 페이지가 완전히 로드될 때까지 잠시 대기time.sleep(3)
    # 검색창 요소 찾기search_box = WebDriverWait(driver, 10).until(    EC.presence_of_element_located((By.CSS_SELECTOR, "#query")))
    # 검색어 입력search_box.clear()  # 기존 입력값이 있다면 지우기search_box.send_keys("크루즈")
    # 검색 버튼 찾기search_button = WebDriverWait(driver, 10).until(    EC.element_to_be_clickable((By.XPATH, '//*[@id="search-btn"]')))
    # 검색 버튼 클릭search_button.click()
    # 검색 결과 페이지가 로드될 때까지 잠시 대기time.sleep(3)
    print("검색이 완료되었습니다.")
    # 브라우저 유지 (필요에 따라 주석 처리)input("Press Enter to close the browser...")
    # 브라우저 종료 (필요에 따라 주석 해제)# driver.quit()


  1. 2번째과제를 하려는데

제가 만들걸로 해보아도, 파트너님 만들어주신걸로 해보아도 유사한 오류가 나는 것 같습니다.



이거 수정하려고 클로드에 6번 물어봐도 같은 결론이 나와서 멈출께요^^😝

2
1개의 답글

👉 이 게시글도 읽어보세요