강의

멘토링

커뮤니티

Inflearn Community Q&A

eodbs01170971's profile image
eodbs01170971

asked

Introduction to Python and Creating Various Automated Applications Using Web Crawling

BeautifulSoup usage and simple web parsing practice (2) - Naver, Inflearn

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

Written on

·

166

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)

웹-크롤링python

Answer 1

0

niceman님의 프로필 이미지
niceman
Instructor

안녕하세요.

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

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

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

eodbs01170971's profile image
eodbs01170971

asked

Ask a question