NanmiCoder/MediaCrawler · error
Request failed, method: {method}, url: {url}, status code: {
Error message
Request failed, method: {method}, url: {url}, status code: {response.status_code} What it means
Raised by BaiduTieBaClient.request (media_platform/tieba/client.py:267) when the underlying HTTP request (executed synchronously via asyncio.to_thread) returns a status code other than 200. The message includes the method, URL, and status code so the failure can be attributed to a specific endpoint. It signals the Tieba API rejecting the request — rate limiting, invalid signature/cookies, expired proxy, or server-side 5xx.
Source
Thrown at media_platform/tieba/client.py:267
"""
# Check if proxy is expired before each request
await self._refresh_proxy_if_expired()
actual_proxy = proxy if proxy else self.default_ip_proxy
# Execute synchronous requests in thread pool
response = await asyncio.to_thread(
self._sync_request,
method,
url,
actual_proxy,
**kwargs
)
if response.status_code != 200:
utils.logger.error(f"Request failed, method: {method}, url: {url}, status code: {response.status_code}")
utils.logger.error(f"Request failed, response: {response.text}")
raise Exception(f"Request failed, method: {method}, url: {url}, status code: {response.status_code}")
if response.text == "" or response.text == "blocked":
utils.logger.error(f"request params incorrect, response.text: {response.text}")
raise Exception("account blocked")
if return_ori_content:
return response.text
return response.json()
async def get(self, uri: str, params=None, return_ori_content=False, **kwargs) -> Any:
"""
GET request with header signing
Args:
uri: Request route
params: Request parameters
return_ori_content: Whether to return original content
View on GitHub (pinned to d6f7c5bb90)
Solutions
- Increase crawl interval (config CRAWLER_MAX_SLEEP_SEC / crawl_interval) to avoid rate limiting
- Re-login via 'cookie' or 'qrcode' LOGIN_TYPE to refresh stored Tieba cookies
- Rotate to a new IP proxy (configure the ip_pool) if the current IP is blocklisted
- Inspect the logged response.text for the specific block/verification message and adjust headers or endpoints accordingly
Defensive patterns
Strategy: retry
Try / catch
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=2, max=30), reraise=True)
async def fetch_notes(client, uri, params):
try:
return await client.get(uri, params=params)
except Exception as e:
if "status code: 4" in str(e) or "status code: 5" in str(e):
raise # retryable
raise # non-retryable statuses surface after attempts Prevention
- Keep crawl_interval / CRAWLER_MAX_SLEEP_SEC high enough to avoid 403/429
- Configure an ip_pool so blocked IPs can be rotated
- Refresh cookies on a schedule for long-running crawls
- Log response bodies (already done by the client) to classify failures
When it happens
Trigger: Any client.get()/client.post() call whose HTTP response status != 200: common cases are 403/429 from anti-crawler rate limiting, 302 redirects when cookies expired, or 5xx from Tieba servers. Also triggered when a bad IP proxy makes every request fail.
Common situations: Crawling too fast without CRAWLER_MAX_SLEEP_SEC delays; stale or missing Tieba cookies (no login); using a dead/blocklisted proxy IP; Baidu rotating API endpoints or tightening signature checks so the signed headers no longer pass.
Related errors
- account blocked
- [BaiduTieBaClient.get] Reached maximum retry attempts, IP is
- Failed to parse JSON from creator notes page: {e}
- XHS request blocked with HTTP {response.status_code}
- get ip error from proxy provider and status code not 200 ...
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/2dea6d952afd18a2.
Report an issue: GitHub.