National Health Commission of China (NHC) Access Skill
Overview
This skill provides programmatic access to the National Health Commission of China website (www.nhc.gov.cn), allowing retrieval of:
- Lists of medical institution announcements and official documents
- Detailed content of specific announcements
- Search results (when available)
Anti-Bot Protection
IMPORTANT: The NHC website uses sophisticated anti-bot protection (likely Ray WAF or similar) that makes direct HTTP requests impossible. The protection includes:
- Challenge-based authentication: Initial requests return HTTP 412 (Precondition Failed)
- JavaScript execution required: A complex obfuscated JavaScript challenge must be executed
- HTTP-only cookies: Two cookies (
5uRo8RWcod0KO,5uRo8RWcod0KP) are set via JavaScript - Browser fingerprinting: Additional checks beyond standard browser detection
This skill uses Playwright with extensive stealth measures and retry logic to bypass this protection.
Rate Limits
Due to the anti-bot protection and JavaScript execution requirements:
- Default timeout: 60 seconds per request
- Maximum retries: 3 attempts with exponential backoff
- Recommended rate: No more than 10 requests per minute
- Note: Each request may take 10-30 seconds due to WAF challenge execution
Functions
1. get_list
Retrieve a paginated list of documents from a category page.
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| url | string | Yes | - | List page URL (e.g., https://www.nhc.gov.cn/wjw/fzszjg/list.shtml) |
| page | integer | No | 1 | Page number to retrieve |
| max_items | integer | No | 50 | Maximum number of items to return |
Returns:
{
"success": true,
"url": "https://www.nhc.gov.cn/wjw/fzszjg/list.shtml",
"title": "Page Title",
"items": [
{
"title": "Document Title",
"url": "https://www.nhc.gov.cn/fys/c100077/202411/xxxxx.shtml",
"date": "2024-11-15"
}
],
"total": 15,
"page": 1,
"pagination": {
"pages": [1, 2, 3, 4, 5],
"has_next": true
},
"accessed_at": "2024-01-15T10:30:00"
}
Common List URLs:
- Medical Institutions:
https://www.nhc.gov.cn/wjw/fzszjg/list.shtml - Policy Documents:
https://www.nhc.gov.cn/wjw/zcwj/list.shtml - News:
https://www.nhc.gov.cn/xcs/yqfkdt/list.shtml
2. get_detail
Retrieve the full content of a specific document.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Full URL to the document (.shtml page) |
Returns:
{
"success": true,
"title": "Document Title",
"content": "Full text content...",
"content_html": "HTML content...",
"content_length": 5432,
"date": "2024-11-15",
"source": "Health Commission",
"author": "Author Name",
"url": "https://www.nhc.gov.cn/fys/c100077/202411/xxxxx.shtml",
"accessed_at": "2024-01-15T10:30:00"
}
3. search
Search for documents by keyword (if available).
Parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| keyword | string | Yes | - | Search keyword |
| category | string | No | null | Category filter |
| max_items | integer | No | 20 | Maximum results |
Returns:
{
"success": true,
"keyword": "医疗",
"category": null,
"results": [
{
"title": "Result Title",
"url": "https://www.nhc.gov.cn/..."
}
],
"total": 50,
"search_url": "https://www.nhc.gov.cn/search?...",
"accessed_at": "2024-01-15T10:30:00"
}
Error Handling
The skill returns structured error responses:
{
"success": false,
"error": "Error message",
"error_code": "ERROR_CODE",
"url": "..."
}
Error Codes:
| Code | Description |
|---|---|
| MISSING_FUNCTION | No function specified in params |
| MISSING_URL | Required URL parameter missing |
| MISSING_KEYWORD | Required keyword parameter missing |
| UNKNOWN_FUNCTION | Invalid function name |
| WAF_BLOCKED | Anti-bot protection blocked the request |
| REQUEST_FAILED | Network or browser error |
| NO_SEARCH | Search functionality not available |
| EXECUTION_ERROR | Unexpected error |
Usage Examples
Example 1: Get list of medical institution announcements
result = await execute({
"function": "get_list",
"url": "https://www.nhc.gov.cn/wjw/fzszjg/list.shtml",
"page": 1,
"max_items": 20
})
if result["success"]:
for item in result["items"]:
print(f"{item['date']}: {item['title']}")
print(f" URL: {item['url']}")
Example 2: Get detailed content
result = await execute({
"function": "get_detail",
"url": "https://www.nhc.gov.cn/fys/c100077/202411/xxxxx.shtml"
})
if result["success"]:
print(f"Title: {result['title']}")
print(f"Date: {result['date']}")
print(f"Content: {result['content'][:500]}...")
Example 3: Search (if available)
result = await execute({
"function": "search",
"keyword": "医疗机构执业登记",
"max_items": 10
})
if result["success"]:
for item in result["results"]:
print(item["title"])
Technical Details
Browser Configuration
The skill uses Playwright with:
- Headless Chromium browser
- Stealth scripts to hide automation markers
- Custom User-Agent (Macintosh Chrome 120)
- Chinese locale (zh-CN) and timezone (Asia/Shanghai)
- WebGL spoofing to appear as real device
Retry Strategy
Requests use exponential backoff:
- Initial request (60s timeout)
- If 412/400: Wait 10s, reload
- If still blocked: Wait 20s, reload
- If still blocked: Wait 40s, reload
- Return error after max retries
Known Limitations
- Intermittent failures: Even with proper stealth measures, the WAF may still block some requests
- Long response times: First request may take 20-30 seconds due to WAF challenge
- Search unavailable: The search function may not work if the site doesn't have public search
- Pagination: Some list pages may use different pagination patterns
Troubleshooting
"WAF_BLOCKED" errors
If you consistently get WAF_BLOCKED errors:
- Reduce request frequency
- Wait between requests (recommend 30+ seconds)
- Try different times of day
- The WAF may update its detection methods
"REQUEST_FAILED" errors
Network or browser errors:
- Check internet connectivity
- The site may be down or slow
- Try increasing timeout parameter
Empty results
If requests succeed but return empty results:
- The page structure may have changed
- Different selectors may be needed
- Content may be loaded dynamically after page load
Dependencies
- playwright >= 1.40.0
- Python >= 3.8
Changelog
v1.0.0 (2024-01-15)
- Initial implementation
- WAF bypass with Playwright stealth
- get_list, get_detail, search functions
- Comprehensive error handling