파이썬 크롤링 기본세팅
Mon Jan 23 2023 15:58:05 GMT+0000 (Coordinated Universal Time)
Saved by
@ncia
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import requests
import time
options = Options()
# options.add_argument('headless')
options.add_experimental_option('detach', True) # 브라우저 바로 닫힘 방지
options.add_experimental_option('excludeSwitches', ['enable-logging']) # 불필요한 메시지 제거
chrome_driver = ChromeDriverManager().install()
print(chrome_driver)
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
options.add_argument(f'--user-agent={UA}')
driver = webdriver.Chrome(chrome_driver, options=options)
# 웹페이지 해당 주소 이동
driver.implicitly_wait(5) # 윂에지가 로딩 될때까지 5초는 기다림
driver.maximize_window() # 화면창 최대화
driver.get('https://www.finnishdesignshop.com/en-us/furniture')
time.sleep(3)
# 로그인 버튼
cookie_btn = driver.find_element(By.CSS_SELECTOR, "#btnAcceptAllCookies")
cookie_btn.click()
content_copyCOPY
Comments