G마켓 크롤링 해보고 있는데 어떻게 해야할지 모르겠어요. 꼭 좀 도와주세요.

조회수 356회

안녕하세요. 지금 시도하고 있는 크롤링은 G마켓에서 키워드로 검색한 내용 중 구매한 목록만 뽑아서 추출하려고 하고 있습니다.

해당 주소는 아래와 같습니다.

https://browse.gmarket.co.kr/search?keyword=%ec%95%8c%ea%b5%ac%ec%8a%ac&f=is:cb

HTML 구조에서 저는 list-item__pay-count가 있는지 없는지를 구분해서 추출하려고 시도하였습니다.

<div class="box__information-score">
<ul class="list__score">
 <li class="list-item list-item__pay-count"><span class="text">구매 
 <!-- -->
 1</span><span class="for-a11y">건</span></li>
</ul>
</div>

그래서 아래와 같이 코드를 짰는데 '.list-item__pay-count' 이게 안나오는거 같아서 어떻게 해야할지 갈피를 못잡고 있습니다.

import requests
from bs4 import BeautifulSoup
import time

res = requests.get("https://browse.gmarket.co.kr/search?keyword=%ec%95%84%ec%9d%b4%ed%8f%b013&f=is:cb")
html = res.text
soup = BeautifulSoup(html, 'html.parser')

item_containers = soup.select(".box__item-container")
for item_container in item_containers :
    if item_container == '.list-item__pay-count' :
        print('test')

꼭 좀 도와주세요 ㅠ_ㅠ

  • 구매내역을 불러오려면 로그인 정보가 있어야 할 텐데요. 초보자 2021.12.31 13:19

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)