• 카테고리

    질문 & 답변
  • 세부 분야

    업무 자동화

  • 해결 여부

    미해결

멜론 유저에이전트 값 입력했음에도 창접속이안되여 ㅜㅜ

24.02.25 21:58 작성 조회수 102

0

#라이브러리
from selenium import webdriver # Selenium의 웹 드라이버를 사용하기 위한 모듈을 임포트
from selenium.webdriver.common.by import By # Selenium에서 사용하는 By 클래스를 임포트합니다. 이 클래스는 웹 요소를 검색하는데 사용
from selenium.webdriver.common.keys import Keys #키보드 입력을 제어하기 위한 Keys 클래스를 임포트
from selenium.webdriver.chrome.service import Service # Chrome 드라이버 서비스를 사용하기 위한 모듈을 임포트
from selenium.webdriver.chrome.options import Options # Chrome 드라이버 옵션을 설정하기 위한 클래스를 임포트
from webdriver_manager.chrome import ChromeDriverManager #Chrome 드라이버를 자동으로 설치 및 관리하는 데 사용되는 매니저를 임포트
import time #시간 관련 함수를 사용하기 위한 time 모듈을 임포

myOption = Options()
myAgent = '''Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36'''
myOption.add_argument(f"user-agent = {myAgent}")
myOption.add_argument("--start-maximized")
myOption.add_experimental_option("detach",True)
myOption.add_experimental_option("excludeSwitches", ["enable-logging"])

myService = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=myService, options=myOption )

url = "https://m2.melon.com/index.htm"

time.sleep(2)

답변 1

답변을 작성해보세요.

0

코드에서
myOption.add_argument(f"user-agent = {myAgent}") 이 부분을
myOption.add_argument(f"user-agent={myAgent}") 이렇게 공백 없이 사용해야 합니다.