inflearn logo
강의

Course

Instructor

Introduction to Python and Creating Various Automated Applications Using Web Crawling

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

직전강의에도 질문드렸었는데

218

SeungMin Hyun

6 asked

0

다시 봐도 이상이 없습니다

f12를 눌러서 copy selector 하면

#main_pack > section > div > div.photo_group._listGrid > div.photo_tile._grid > div:nth-child(1) > div > div.thumb > a > img

가 나오고 여기서 저는

div.thumb > a > img를 선택 했습니다 

그러나 역시 결과는 저번 강의때와 마찬가지로 빈 리스트만 출력됩니다

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:/python/img_down"

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.thumb > a > img")

print("test", img_list)

test []
[Finished in 0.305s]

웹-크롤링 python

Answer 1

0

niceman

안녕하세요.

영상 후반부에 나오는 selenium을 활용해서 크롤링하시면 됩니다.

확인해보니 현재 ajax 형식으로 변경된 듯 합니다.

현재 예제에서 error 발생

0

367

3

유튜브 동영상 다운로드

0

1448

2

Atom 에디터 관련

0

337

1

위시켓 폼데이터

0

274

1

스케줄러 사용 관련 질문 드립니다

0

627

1

selenium 에러

0

428

1

Progress bar 쓰레드 관련

0

489

1

Install Package 관련 문의

0

328

1

tkinter 샘플 코드 실행 오류 건

0

1267

1

4-7-6 네이버 & 카카오 주식 정보 가져오기

0

381

1

네이버자동로그인_by_selenium

0

876

1

위시캣 로그인 처리 및 크롤링 질문

0

344

1

2-8-1 네이버이미지 크롤링 질문

1

604

3

li:nth-of-type 질문

0

350

2

에러가 뜨는데 잘 모르겠어요ㅠ

0

401

2

Install Packages 항목이 안보이는 이유가 뭘까요?

0

400

2

환경변수 Path 설정 방법

0

631

1

웹 브라우저 없는 스크랩핑 및 파싱 실습(1) - 인프런

0

333

1

웹 브라우저 없는 스크랩핑 및 파싱 실습(1) -git주소

0

475

3

download2-8-1. py질문

0

203

1

ip 차단 당하는 거 같은데 아무리 랜덤주고, sleep 줘도 안 되는데 다른 방법 더 있을까요??

0

645

1

인프런 환경이 바뀌어서 제나름대로 하는데

0

196

1

다시올려주신 예제파일로하는데

0

190

1

아직도 에러가뜨나보네요?

0

584

1