mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-22 06:17:54 +00:00
🐛 修复当爬取数据时出现 SSLZeroReturnError
错误后无法继续爬取数据的问题
This commit is contained in:
parent
ffb404e43b
commit
04b684bb2e
@ -3,6 +3,7 @@ import re
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from asyncio import Queue
|
from asyncio import Queue
|
||||||
from multiprocessing import Value
|
from multiprocessing import Value
|
||||||
|
from ssl import SSLZeroReturnError
|
||||||
from typing import AsyncIterator, ClassVar, List, Optional, Tuple, Union
|
from typing import AsyncIterator, ClassVar, List, Optional, Tuple, Union
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
@ -81,7 +82,7 @@ class WikiModel(Model):
|
|||||||
for _ in range(retry_times):
|
for _ in range(retry_times):
|
||||||
try:
|
try:
|
||||||
return await cls._client.get(url, follow_redirects=True)
|
return await cls._client.get(url, follow_redirects=True)
|
||||||
except HTTPError:
|
except (HTTPError, SSLZeroReturnError):
|
||||||
await anyio.sleep(sleep)
|
await anyio.sleep(sleep)
|
||||||
return await cls._client.get(url, follow_redirects=True) # 防止 retry_times 等于 0 的时候无法发生请求
|
return await cls._client.get(url, follow_redirects=True) # 防止 retry_times 等于 0 的时候无法发生请求
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user