프로그램 분류
파이썬기초134 : 웹크롤링 예제07
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 2,459 조회
- 0 추천
- 목록
본문
import os
import requests
from bs4 import BeautifulSoup
WEBTOON_NAME = 'hanobaek'
res = requests.get('http://comics.nate.com/webtoon/detail.php?btno=48746&bsno=280510#view')
res.raise_for_status()
#print res.text
soup = BeautifulSoup(res.text, "html.parser")
#print soup
result = soup.select('.toonView')
#print result
image = result[0].select('img')
#print image
newDirPath = os.path.join(os.getcwd(), WEBTOON_NAME)
os.mkdir(newDirPath)
for i in range(0, len(image)):
#print image[i]['src']
cut = requests.get(image[i]['src'])
cutFile = open(os.path.join(newDirPath, str(i) + '.jpg'), 'wb')
for chunk in cut.iter_content(100000):
cutFile.write(chunk)
cutFile.close()
print "Images downloaded.... Done"
"무단배포금지: 클라우드포털(www.linux.co.kr)의 모든 강좌는 저작권에 의해 보호되는 콘텐츠입니다. 무단으로 복제하여 배포하는 행위는 금지되어 있습니다."
관련자료
-
이전
-
다음
댓글 0
등록된 댓글이 없습니다.