fix httpx

This commit is contained in:
jxxghp
2025-07-31 13:51:43 +08:00
parent 6afdde7dc1
commit 983f8fcb03
3 changed files with 7 additions and 25 deletions
+2 -8
View File
@@ -12,7 +12,6 @@ import requests
from app.core.cache import cached
from app.core.config import settings
from app.utils.asyncio import AsyncUtils
from app.utils.http import RequestUtils, AsyncRequestUtils
from app.utils.singleton import WeakSingleton
@@ -156,7 +155,6 @@ class DoubanApi(metaclass=WeakSingleton):
def __init__(self):
self._session = requests.Session()
self._client = httpx.AsyncClient()
@classmethod
def __sign(cls, url: str, ts: str, method='GET') -> str:
@@ -251,8 +249,7 @@ class DoubanApi(metaclass=WeakSingleton):
"""
req_url, params = self._prepare_get_request(url, **kwargs)
resp = await AsyncRequestUtils(
ua=choice(self._user_agents),
client=self._client
ua=choice(self._user_agents)
).get_res(url=req_url, params=params)
return self._handle_response(resp)
@@ -297,8 +294,7 @@ class DoubanApi(metaclass=WeakSingleton):
"""
req_url, params = self._prepare_post_request(url, **kwargs)
resp = await AsyncRequestUtils(
ua=settings.NORMAL_USER_AGENT,
client=self._client
ua=settings.NORMAL_USER_AGENT
).post_res(url=req_url, data=params)
return self._handle_response(resp)
@@ -876,5 +872,3 @@ class DoubanApi(metaclass=WeakSingleton):
def close(self):
if self._session:
self._session.close()
if self._client:
AsyncUtils.run_async(self._client.aclose())