This commit is contained in:
岛风 2019-09-16 01:51:49 +08:00
parent d09e768569
commit be39b162ee

View File

@ -36,7 +36,14 @@ class PixivSpider(object):
print(f'{file_name}已存在!')
return 1
print(f'开始下载:{file_name}')
img_temp = requests.get(url, headers=self.headers)
t = 0
while t < 3:
try:
img_temp = requests.get(url, headers=self.headers, timeout=15)
break
except requests.exceptions.ConnectTimeout:
print("连接超时!正在重试!")
t += 1
with open(f'./img/{file_name}', 'wb') as fp:
fp.write(img_temp.content)