import requests from retrying import retry # 设置重试次数和超时时间 retry_times = 3 timeout = 0.2 # 重试装饰器 @retry(stop_max_attempt_number=retry_times, wait_fixed=timeout*10) def get_url(url): response = requests.get(url=url, timeout=timeout) print(response.status_code)
标签:retry,get,url,练习,爬虫,timeout,import,一些,response From: https://www.cnblogs.com/xu-he/p/17458951.html