代码如下:
import urllib
import urllib.request
def get_image(url,stuNum):
try:
request = urllib.request.Request(url)
response = urllib.request.urlopen(request)
get_img = response.read()
with open(‘D:\stuphoto\’+str(stuNum)+’.jpg’,‘wb’) as fp:
fp.write(get_img)
print(‘图片下载完成’)
except:
print(‘访问空’)
stuNum =
url = ‘’
for i in range(500):
stuNum = stuNum+1
get_image(url+str(stuNum)+’.JPG’,stuNum)