from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.chrome()
driver.get("https://search.shopping.naver.com/search/all?frm=NVSHATC&origQuery=%EC%9E%A5%EC%96%B4")
shop_name = driver.find_elements(By.TAG_NAME, 'li')
for e in shop_name:
print(e.text)
요소내에서 요소 찾기 - ul 요소 내에서 li 찾아서 출력
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.chrome()
driver.get("https://search.shopping.naver.com/search/all?frm=NVSHATC&origQuery=%EC%9E%A5%EC%96%B4")
shop = driver.find_elements(By.TAG_NAME, 'ul')
shop_names = shop.find_elements(By.TAG_NAME, 'li')
for e in shop_names:
print(e.text)
요소추적하기 - 상품제목 추적하기
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://search.shopping.naver.com/search/all?frm=NVSHATC&origQuery=%EC%9E%A5%EC%96%B4")
driver.find_element(By.CSS_SELECTOR, '[class="imgList_list_item__zYg0L"]').send_keys("webElement")
title_data = driver.switch_to.active_element.get_attribute("a")
print(title_data)