# coding=utf-8
import lxml,bs4,re,requests
csvContent=''
file = open('D:\\tyc_demo.html','rb')
soup = bs4.BeautifulSoup(file,'html.parser')
pics=soup.find_all(attrs={'class': 'origin_image zh-lightbox-thumb lazy'})
for pic in pics:
link = str(pic)
link = link[(link.index('data-original="')+15):link.index('" data-rawheight=')]
print(link)
print()
resultPage = requests.get(link)
with open(('E:\\pics\\'+link[26:]),'wb') as file:
file.write(resultPage.content)
print(csvContent)
博客地址:https://blog.csdn.net/xiang__liu,https://www.cnblogs.com/xiang--liu/