# 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)

posted on 2018-02-10 14:49  刘达人186  阅读(126)  评论(0编辑  收藏  举报