강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

하얀엿님의 프로필 이미지
하얀엿

작성한 질문수

파이썬 입문 및 웹 크롤링을 활용한 다양한 자동화 어플리케이션 제작하기

BeautifulSoup 사용법 및 간단 웹 파싱 실습(2) - 네이버, 인프런

2-8-1 질문드립니다..

작성

·

167

0

네이버 태그가 바껴서 해본다고 해봤는데 print해봤는데 아무것도 나오질 않아요..

from bs4 import BeautifulSoup

import urllib.request as req

import urllib.parse as rep

import sys

import io

import os

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')

sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')

base = "https://search.naver.com/search.naver?where=image&sm=tab_jum&query="

quote = rep.quote_plus("사자")

url = base + quote

res = req.urlopen(url)

savePath = "c:\\imagedown\\" # C:\imagedown\ 윈도우는 \대신 / 써도 상관x

try:

    if not (os.path.isdir(savePath)):

        os.makedirs(os.path.join(savePath))

except OSError as e:

    if e.errno != errno.EEXIST:

        print("폴더 만들기 실패")

        raise

soup = BeautifulSoup(res, "html.parser")

img_list = soup.select("div.photo_bx api_ani_send._photoBox > div.thumb > a.link_thumb._imageBox._infoBox > img")

print("test", img_list)

답변 1

0

좋은사람님의 프로필 이미지
좋은사람
지식공유자

안녕하세요.

지금 현재 이미지를 따로 불러오는 방식으로 rendering이 변경되었습니다.

뒤에 배울 selenium으로 처리하실 수가 있으세요.

조만간 selenium 버전으로 변경해서 소스코드 올려드리겠습니다.

하얀엿님의 프로필 이미지
하얀엿

작성한 질문수

질문하기