import requests
import urllib.request
from bs4 import BeautifulSoup
header = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"}
url="https://www.meizitu.com/a/5521.html"
res=requests.get(url,headers=header)
res.encoding = res.apparent_encoding
html=res.text
soup = BeautifulSoup(html, 'html.parser')
meizi=soup.find_all("img")
x=1
for i in meizi:
imgsrc=i.get('src')
print(imgsrc)
urllib.request.urlretrieve(imgsrc, './妹子/%s.jpg' %x)
x=x+1
把url="https://www.zhihu.com/question/302378021/answer/557792503"
for i in meizi[1::2]: [1::2]代表从第二个开始 隔一个隔一个取出直到最后
两句改了可以爬知乎的表情包 具有一定的普适性