커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
기타적인 질문(크롤링)
undefined주차
북마크
오*은
댓글
10
추천
0
조회수
65
조회수
65
답변 완료

지니 뮤직 크롤링 했던 것 처럼 무신사 실시간 랭킹을 크롤링 해보려고 하는데 1위만 나오고 안나오네요!


뭐가 문제일까요?


무신사와 다르게 지니 뮤직은 테이블 형식으로 html이 짜여져 있어서 정보를 가져오는 게 수월했던 걸까요?

import requests
from bs4 import BeautifulSoup

from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.rfofzeu.mongodb.net/Cluster0?retryWrites=true&w=majority')
db = client.dbsparta

headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get('https://www.musinsa.com/app/',headers=headers)

soup = BeautifulSoup(data.text, 'html.parser')

clothes = soup.select('#ranking_goods > div:nth-child(19) > ul')
for clothe in clothes:
    a = clothe.select_one('li:nth-child(1) > div.ranking_item_intro > p.txt_tit_brand')
    if a is not None:
        title = a.text
        rank = clothe.select_one('li:nth-child(1) > p').text.strip()
        comment = clothe.select_one('li:nth-child(1) > div.ranking_item_intro > p:nth-child(2) > a').text.strip()
        image = clothe.select_one('li:nth-child(1) > div.ranking_item_img > a > img')['src']
        print(rank, image, title, comment)
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴