URL에서 모든 이미지를 추출하고 다운로드하려고합니다. 내가beautifulSoup를 사용하여 웹 사이트에서 모든 이미지를 추출하고 다운로드하는 방법은 무엇입니까?
import urllib2
import re
from os.path import basename
from urlparse import urlsplit
url = "http://filmygyan.in/katrina-kaifs-top-10-cutest-pics-gallery/"
urlContent = urllib2.urlopen(url).read()
# HTML image tag: <img src="url" alt="some_text"/>
imgUrls = re.findall('img .*?src="(.*?)"', urlContent)
# download all images
for imgUrl in imgUrls:
try:
imgData = urllib2.urlopen(imgUrl).read()
fileName = basename(urlsplit(imgUrl)[2])
output = open(fileName,'wb')
output.write(imgData)
output.close()
except:
pass
가 난 그냥 "다음"버튼을 클릭하지 않고 모든 이미지를 얻으려면 http://i.share.pho.to/1c9884b1_l.jpeg 이 이미지를보고이 페이지의 이미지를 추출하고 싶지 않은 스크립트를 작성 내가 어떻게 할 수지고 있지 않다 나는 "다음"수업에서 모든 사진을 얻는다.? 내가 findall에서해야 할 일은 무엇인가?
BeautifulSoup를 사용하고 싶지만 진행 방법을 잘 모르시겠습니까? –
예. findall 또는 findnext를 어떻게 사용해야합니까? 위의 스크립트는 해당 URL의 모든 이미지를 가져 오지만 다음 버튼을 클릭하면 오는 슬라이드 쇼의 모든 이미지를 가져오고 싶습니다 (이미지 링크 참조). – user2711817
사용 [wget] (http://stackoverflow.com/questions/4602153/how-do-i-use-wget-to-download-all-images-into-a-single-folder) –