发送POST请求并返回文本响应
(url: str, params: str, cookies: Dict[str, str])
| 108 | |
| 109 | @staticmethod |
| 110 | def post_request(url: str, params: str, cookies: Dict[str, str]) -> str: |
| 111 | """发送POST请求并返回文本响应""" |
| 112 | headers = { |
| 113 | 'User-Agent': APIConstants.USER_AGENT, |
| 114 | 'Referer': APIConstants.REFERER, |
| 115 | } |
| 116 | |
| 117 | request_cookies = APIConstants.DEFAULT_COOKIES.copy() |
| 118 | request_cookies.update(cookies) |
| 119 | |
| 120 | try: |
| 121 | response = requests.post(url, headers=headers, cookies=request_cookies, |
| 122 | data={"params": params}, timeout=30) |
| 123 | response.raise_for_status() |
| 124 | return response.text |
| 125 | except requests.RequestException as e: |
| 126 | raise APIException(f"HTTP请求失败: {e}") |
| 127 | |
| 128 | @staticmethod |
| 129 | def post_request_full(url: str, params: str, cookies: Dict[str, str]) -> requests.Response: |
no test coverage detected