# -*- coding:utf-8 -*- import requests,asyncio,aiohttp,os,time def run_time(fn): '''装饰器,用于查看图片下载运行时间''' def wrapper(*args, **kwargs): start = time.time() fn(*args, **kwargs) print('运行时间{}'.format(time.time() - start)) return wrapper class Crawl_Image: def __init__(self): self.num = 1 if '图片' not in os.listdir('.'): os.mkdir('图片') self.path = os.path.join(os.path.abspath('.'),'图片') os.chdir(self.path) def str_dict(self): '''把字符串转化成字典,通常的请求头一个一个写成字典麻烦''' headers = {} heads = ''' authority: unsplash.com method: GET path: /napi/photos?page=13&per_page=12&order_by=latest scheme: https accept: */* accept-encoding: gzip, def