• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 분석

  • 해결 여부

    미해결

네이버쇼핑 질문 있습니다!

24.07.01 23:22 작성 조회수 28

0

네이버쇼핑크롤링을 연습도중 상품썸네일 링크를 가져와보고싶어서 연습을해봤는데 아래링크처럼했을때 첫번째 상품의 이미지링크만 가져오게되고 나머지 이미지썸네일 링크는 여러가지 다른선택자를 이용해서 시도를 해봤지만 이와같이 한개의 이미지썸네일 링크만 가져와져서 이럴때 어떻게 해야될지 궁금합니다!

image.png

from selenium import webdriver
import time
from bs4 import BeautifulSoup
import re
from urllib.parse import urlparse, urlunparse

driver = webdriver.Chrome()

driver.get('https://search.shopping.naver.com/search/all?adQuery=%EB%8B%AD%ED%84%B8%EB%BD%91%EB%8A%94%EA%B8%B0%EA%B3%84&origQuery=%EB%8B%AD%ED%84%B8%EB%BD%91%EB%8A%94%EA%B8%B0%EA%B3%84&pagingIndex=1&pagingSize=40&productSet=overseas&query=%EB%8B%AD%ED%84%B8%EB%BD%91%EB%8A%94%EA%B8%B0%EA%B3%84&sort=review&sps=N&timestamp=&viewType=list')

last_height = driver.execute_script("return document.body.scrollheight")

while True:
    #스크롤끝까지 내리기
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    time.sleep(2)
    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break
    last_height = new_height

html = driver.page_source
soup = BeautifulSoup(html, 'html.parser') 

items = soup.select(".product_item__MDtDF")
for item in items:
    # 이미지 URL 찾기
    img = item.select_one(".product_img_area__cUrko img")
    print(img)

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!

채널톡 아이콘