爬取爱套图网上的图片
# coding = utf-8 from bs4 import BeautifulSoup import requests for i in range(20): i = str(i) url = 'https://www.aitaotu.com/weimei/16359_' + i + '.html' html = requests.get(url=url) html = html.text a_bf = BeautifulSoup(html, "html.parser") a = a_bf.find('div', class_='big-pic').find_all('img') # print(a) pic_names = [] pic_urls = [] for each in a: pic_names.append(each.get('alt')) pic_urls.append(each.get('src')) path = '/Users/ydj/Desktop/image/' ii = len(pic_names) for i in range(ii): img = requests.get(pic_urls[i]) with open(path + pic_names[i] + '.jpg', 'wb') as f: f.write(img.content) print(pic_names[i])
简单的写些代码,具体的有时间详细补充