fix: 修复小红书client中get请求中文bug

This commit is contained in:
Relakkes 2023-11-23 23:27:35 +08:00
parent 3790e8041e
commit 6908da6f70
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import json import json
from typing import Dict, Optional from typing import Dict
from urllib.parse import urlencode
import httpx import httpx
from playwright.async_api import BrowserContext, Page from playwright.async_api import BrowserContext, Page
@ -70,7 +71,7 @@ class XHSClient:
final_uri = uri final_uri = uri
if isinstance(params, dict): if isinstance(params, dict):
final_uri = (f"{uri}?" final_uri = (f"{uri}?"
f"{'&'.join([f'{k}={v}' for k, v in params.items()])}") f"{urlencode(params)}")
headers = await self._pre_headers(final_uri) headers = await self._pre_headers(final_uri)
return await self.request(method="GET", url=f"{self._host}{final_uri}", headers=headers) return await self.request(method="GET", url=f"{self._host}{final_uri}", headers=headers)