데이터 수집 - 크롤링

Daum·2021년 3월 10일
0

Big Data

목록 보기
3/7
post-thumbnail

📝 데이터 수집 - 크롤링

파이썬 언어를 기반으로 크롤링하여 데이터를 수집하려고 한다.
쇼핑몰 웹사이트의 주간 인기 상품 랭킹 데이터를 수집하고,
데이터를 분석 및 시각화하여 유의미한 아웃풋으로 만드는 것이 목적이다.

✍🏻 [작업 환경]
Python 3.8

✍🏻 [파이썬 라이브러리]
re
requests
BeautifulSoup
import re
import requests
from bs4 import BeautifulSoup

url = 'https://search.musinsa.com/ranking/best?period=week&age=ALL&mainCategory=&subCategory=&leafCategory=&price=&golf=false&newProduct=false&exclusive=false&discount=false&soldOut=false&page=1&viewType=small&device=&priceMin=&priceMax='
html = requests.get(url)
soup = BeautifulSoup(html.text)

#특정 데이터만 추출
mus_brand = str(soup.find_all('p', 'item_title'))
mus_product = str(soup.find_all('p', 'list_info'))

#텍스트만 출력(태그제거)
mus_brands=re.sub('<.+?>', '', mus_brand, 0).strip()
mus_products=re.sub('<.+?>', '', mus_product, 0).strip()

print(mus_brands)
print(mus_products)

0개의 댓글