ホームページ >バックエンド開発 >Python チュートリアル >Web ページから画像をクローリングする Python の例
def getImg(html,imgType):
reg = r'src="(.*?.+'+imgType+'!slider)" '
imgre = re.compile(reg)
imgList = re.findall(imgre, html)
x=0
imgList の imgurl:
print imgurl
urllib.urlretrieve(imgurl, '%s.%s' % (x, imgType) ))
x =x+1
html= getHTML("http://www.jb51.net")
getImg(html,'jpg')