class명이 랜덤인건가.. 우선 몇가지 사이트 확인했을때 가져와짐, 랜덤으로 하는 이유가 있구나? https://medium.com/developers-tomorrow/why-google-use-random-classname-81b4c363a4e0 스마트스토어는 오른쪽 마우스를 막았지만 상세정보쪽에서는 우클릭이 가능
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import requests
from bs4 import BeautifulSoup
import urllib.request
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"}
response = requests.get(url, headers=headers)
response.raise_for_status()
soup = BeautifulSoup(response.content, 'html.parser')
# image_url
soup.find("div", class_="_23RpOU6xpc").find("img").get("src")
# title
soup.find("div", class_="CxNYUPvHfB").find("h3").text
# price (할인전가격)
soup.find("span", class_="_1LY7DqCnwR").text + "원"
# price (할인가격)
soup.find_all("span", class_="_1LY7DqCnwR")[1].text + "원"