import os
import urllib.request
from bs4 import BeautifulSoup
from selenium import webdriver
driver_path = "C:\\work\\webdriver.exe"
options = webdriver.ChromeOptions()
options.add_argument("headless")
options.add_argument("disable-gpu")
browser = webdriver.Chrome(chrome_driver_binary=driver_path, options=options) # 코드 수정
url = 'https://smartstore.naver.com/bebenuvo/products/4922209638#REVIEW'
browser.get(url)
soup = BeautifulSoup(browser.page_source, 'html.parser')
image_tags = soup.find_all('img', class_='bg6swaDc6G')
def save_image(image_url, file_path):
with urllib.request.urlopen(image_url) as response, open(file_path, 'wb') as out_file:
out_file.write(response.read())
save_path = "C:\\work"
for idx, img_tag in enumerate(image_tags):
image_url = img_tag['src']
file_name = f"{idx + 1}.jpg"
file_path = os.path.join(save_path, file_name)
save_image(image_url, file_path)
print("이미지 다운로드 완료")
browser.quit()
이거 ---------------------------------------------------------------------------
TypeError Traceback (most recent call last) <ipython-input-15-af0abdeb5aeb> in <cell line: 12>() 10 options.add_argument("disable-gpu") 11 ---> 12 browser = webdriver.Chrome(chrome_driver_binary=driver_path, options=options) # 코드 수정 13 url = 'https://smartstore.naver.com/bebenuvo/products/4922209638#REVIEW' 14 browser.get(url)TypeError: WebDriver.__init__() got an unexpected keyword argument 'chrome_driver_binary' 자꾸 이딴식으로 오류나서 executable_path 이거로 바꿨더니 그래도 오류나고 옵션 오류나고 옘병 진짜
여기말고 갓택오버플로우에 물어보자
https://www.selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html#module-selenium.webdriver.chrome.webdriver
options말고도
기존 exexutable_path는 Service 객체로 이전된것같은데용