python爬取碧蓝航线所有战舰头像
import urllib
import requests
from bs4 import BeautifulSoup
res = requests.get('http://wiki.joyme.com/blhx/%E9%A6%96%E9%A1%B5')
soup = BeautifulSoup(res.text, 'html.parser', )
images = soup.select('img')
for image in images:
name = image.get('data-file-name')
link = image.get('src')
fileFormat = link[-3:]
if fileFormat == 'jpg' and len(str(name))>6 and str(name[-6:])=='头像.jpg':
print(name[-6:])
print(link)
#这里的引号里写你想要保存的位置
fileSavePath = 'D:/Study/file/'+str(name)
urllib.request.urlretrieve(link, fileSavePath)