#-*- coding: utf-8 -*-
import urllib2
import urllib
import os
from BeautifulSoup import BeautifulSoup def getAllImageLink():
# 需要下载图片的地址
html = urllib2.urlopen('http://www.win4000.com/meinvtag34.html').read()
soup = BeautifulSoup(html) liResult = soup.findAll('li',attrs={"class":"box"})
numberIndex = 0
for li in liResult:
imageEntityArray = li.findAll('img')
for image in imageEntityArray:
link = image.get('src')
imageName = 'image' + str(numberIndex)
numberIndex = numberIndex + 1
# 下载到的地址
filesavepath = 'C:\\Users\\Administrator\\Desktop\\py\\%s.jpg' % imageName
urllib.urlretrieve(link,filesavepath)
print filesavepath if __name__ == '__main__':
getAllImageLink()