파이썬 스마트스토어 썸네일 이미지를 가져오는 코드를 만들었습니다.
조회수 686회
import requests
from bs4 import BeautifulSoup
import urllib.request
url = input('주소를 입력하세요: ')
html = requests.get(url)
bs = BeautifulSoup(html.text, 'html.parser')
description = bs.find('meta', property = 'og:image')
sumimg_url = description["content"]
saveName = r"C:\Users\air_c\OneDrive\바탕 화면\이미지저장\itemimg.jpg"
urllib.request.urlretrieve(sumimg_url, saveName)
print('저장되었습니다.')
▲ 위와 같은 코드를 짜서 네이버 스마트 스토어에 있는 썸네일 이미지를 가져오려고 합니다.
그런데 1번의 링크 주소에 있는 썸네일 이미지는 잘 긁어오면서
2번의 링크 주소에 있는 썸네일 이미지는 못가져옵니다.
도대체 이유가 뭘까요? ㅠㅠ
1번 URL: https://brand.naver.com/oastore/products/5127884368?NaPm=ct%3Dkiom8cco%7Cci%3D729f614681d716eb7507e299836735c696349a7a%7Ctr%3Dsbtp%7Csn%3D256847%7Chk%3Da316810714221612f5c5960ff188691cc75a3b08 2번 URL: https://smartstore.naver.com/sumom/products/4779090184?NaPm=ct%3Dkiomyg60%7Cci%3D6a7489be1f2896907a887e156c6e3b467d5f5aba%7Ctr%3Dslsc%7Csn%3D293779%7Chk%3D99ddcc0202b196bfa5d2192165c0c867119d6103
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
주신 2번 URL의 robots.txt가 접근금지로 되어있네요.
User-agent : * Disallow : /
이런 경우에는 크롤링이 불가능합니다.
댓글 입력