-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
직전강의에도 질문드렸었는데
21.07.07 14:29 작성 조회수 114
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]
답변을 작성해보세요.
0
답변 1