{
  "markdown": "<!-- Language toggle -->\n**English** | [中文](README.zh-CN.md)\n\n# 🔍 Baidu API: Structured Baidu Search Results in Clean JSON\n\n> The most efficient, reliable, and developer-friendly way to use the Baidu API.\n\n**Actor page:** [apify.com/johnvc/Baidu-Search-Scraper](https://apify.com/johnvc/Baidu-Search-Scraper?fpr=9n7kx3)\n**Input schema:** [apify.com/johnvc/Baidu-Search-Scraper/input-schema](https://apify.com/johnvc/Baidu-Search-Scraper/input-schema?fpr=9n7kx3)\n\nThe Baidu API (百度) runs a Baidu search for any keyword and returns clean, structured JSON. Each run gives you organic results (title, link, snippet, position), answer boxes, related videos, \"people also search for\" suggestions, related searches, and trending top searches, plus per-page metadata and pagination details. It supports desktop, mobile, and tablet results, Simplified and Traditional Chinese localization, time-range filtering, and multi-page pagination.\n\n## Video Walkthrough\n\n[![Watch the walkthrough](https://img.youtube.com/vi/jREWahDGhJM/maxresdefault.jpg)](https://www.youtube.com/watch?v=jREWahDGhJM)\n\n## Quick Start\n\n### Prerequisites\n- Python 3.11 or higher\n- An Apify account and API key ([get a free key here](https://apify.com?fpr=9n7kx3))\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/johnisanerd/Apify-Baidu-Search-Scraper.git\n   cd Apify-Baidu-Search-Scraper\n   ```\n\n2. **Install dependencies with UV**\n   ```bash\n   # Install UV if you do not have it:\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n\n   # Install project dependencies:\n   uv sync\n   ```\n\n3. **Configure your API key**\n   ```bash\n   cp .env.example .env\n   # Edit .env and add your Apify API key\n   # Get your free API key at: https://apify.com?fpr=9n7kx3\n   ```\n\n4. **Run the example**\n   ```bash\n   uv run python baidu-search-scraper.py\n   ```\n\n### Alternative: set the API key directly\n```bash\nexport APIFY_API_TOKEN=\"your_api_key_here\"\nuv run python baidu-search-scraper.py\n```\n\n## Why Use This Baidu API?\n\n**Complete SERP coverage.** One call returns the full Baidu results page as structured data: organic listings, answer boxes, related videos, \"people also search for\", related searches, and trending top searches. You get the whole page, not just ten blue links.\n\n**Built for China-market research.** Target Simplified or Traditional Chinese results, switch between desktop, mobile, and tablet, and filter by a precise date range. That makes it practical for SEO, market research, and brand monitoring in Chinese-language markets.\n\n**Predictable, pay-per-use pricing.** Billing is per run plus per page processed, with no monthly rental. You pay for the searches you actually make, and you control cost directly with the page limit.\n\n**Clean, consistent JSON.** Every response uses the same shape, so you parse results once and reuse the code across queries. Per-page metadata and pagination details make it easy to page through larger result sets.\n\n**Easy to automate.** Call it from Python in a few lines, or load it as an MCP tool so assistants like Claude and Cursor can run Baidu searches for you on demand.\n\n## Features\n\n### Core Capabilities\n- **Keyword search** across Baidu with full results-page extraction\n- **Device targeting** for desktop, mobile, and tablet results\n- **Language localization** for all languages, Simplified Chinese, or Traditional Chinese\n- **Time-range filtering** using Unix timestamp windows\n- **Multi-page pagination** with a configurable page limit\n\n### Data Quality\n- **Structured organic results** with title, link, snippet, position, and rich data\n- **Rich result blocks**: answer boxes, related videos, people also search for, related searches, top searches\n- **Per-page metadata** with result counts and pagination details\n- **Consistent JSON** shape across every query\n- **Per-page billing** so larger searches stay transparent\n\n## Usage Examples\n\n### Basic Example\nA single-page desktop search for one keyword. This is the cheapest way to try the API.\n```json\n{\n  \"query\": \"machine learning\",\n  \"device\": \"desktop\",\n  \"max_pagination\": 1\n}\n```\n\n### Advanced Example\nA multi-field search with Simplified Chinese localization, more results per page, and a date-range filter.\n```json\n{\n  \"query\": \"机器学习\",\n  \"device\": \"desktop\",\n  \"localization\": 2,\n  \"page\": 1,\n  \"num_results\": 20,\n  \"time_period\": \"stf=1748994000,1749600000|stftype=1\",\n  \"max_pagination\": 3\n}\n```\n\n## Input Parameters\n\n| Parameter | Type | Required | Default | Description |\n|-----------|------|----------|---------|-------------|\n| `query` | `string` | Yes | - | The search term to look up on Baidu. |\n| `device` | `string` | No | `desktop` | Device to simulate: `desktop`, `mobile`, or `tablet`. |\n| `localization` | `integer` | No | `1` | Language filter: `1` = all languages, `2` = Simplified Chinese, `3` = Traditional Chinese. |\n| `page` | `integer` | No | `1` | Starting page number for results. |\n| `num_results` | `integer` | No | `10` | Results to retrieve per page (max 50). |\n| `time_period` | `string` | No | (none) | Date-range filter using Unix timestamps, format `stf=START_UNIX,END_UNIX|stftype=1`. Leave blank for all dates. |\n| `max_pagination` | `integer` | No | `3` | Maximum pages to fetch (`0` = no limit). |\n| `output_file` | `string` | No | (none) | Optional filename to save results; auto-generated if omitted. |\n\n## Output Format\n\nA representative response for the query `machine learning`. Some related arrays are trimmed here for readability; they are returned with the same per-item structure shown for `organic_results`.\n\n```json\n{\n  \"query\": \"machine learning\",\n  \"device\": \"desktop\",\n  \"localization\": 1,\n  \"page\": 1,\n  \"num_results\": 10,\n  \"filter_results\": null,\n  \"time_period\": null,\n  \"max_pagination\": 3,\n  \"total_results_found\": 29,\n  \"pages_processed\": 3,\n  \"search_metadata\": {\n    \"device\": \"desktop\",\n    \"localization\": 1,\n    \"filter_results\": null,\n    \"time_period\": null,\n    \"max_pagination\": 3,\n    \"pagination_limit_reached\": true\n  },\n  \"pagination_info\": {\n    \"total_pages\": 3,\n    \"current_page\": 1,\n    \"max_pagination_set\": 3,\n    \"pagination_stopped_by_limit\": true\n  },\n  \"organic_results\": [\n    {\n      \"position\": 2,\n      \"title\": \"机器学习 - 百度百科\",\n      \"link\": \"https://baike.baidu.com/item/机器学习/217599\",\n      \"displayed_brand\": \"百度百科\",\n      \"snippet\": \"机器学习是一门多领域交叉学科，涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科。\"\n    },\n    {\n      \"position\": 6,\n      \"title\": \"MACHINE LEARNING Definition & Meaning - Merriam-Webster\",\n      \"link\": \"https://www.merriam-webster.com/dictionary/machine%20learning\",\n      \"snippet\": \"machine learning noun: a computational method that is a subfield of artificial intelligence and that enables a computer to learn to perform tasks by analyzing a large dataset.\"\n    }\n  ],\n  \"answer_box\": [],\n  \"related_videos\": [],\n  \"people_also_search_for\": [],\n  \"related_searches\": [],\n  \"top_searches\": []\n}\n```\n\n---\n\n## Use as an MCP tool\n\nYou can load the Baidu API as an MCP tool so assistants call it for you. The MCP server URL preloads just this one Actor:\n\n```\nhttps://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\n```\n\nAuthenticate with OAuth in the browser when offered, or with your Apify API token (the same `APIFY_API_TOKEN` used by the Python example). Get a token at https://console.apify.com/settings/integrations and a free Apify account at https://apify.com?fpr=9n7kx3 .\n\n## Install in Claude Cowork Desktop\n\n![Install in Claude Cowork Desktop](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_desktop.png)\n\nCowork is the desktop app's automation mode. To give it the Baidu API as a tool, add the Apify MCP server as a connector.\n\n1. Open the Claude desktop app and go to **Settings → Connectors** (or **Settings → Developer → Edit Config** to edit `claude_desktop_config.json` directly).\n   - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`\n   - Windows: `%APPDATA%\\Claude\\claude_desktop_config.json`\n2. Add the Apify MCP server, preloaded with only this Actor:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"command\": \"npx\",\n      \"args\": [\n        \"-y\",\n        \"mcp-remote\",\n        \"https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\"\n      ]\n    }\n  }\n}\n```\n\n3. Restart the app. When Cowork first calls the tool, complete the OAuth prompt in your browser, or add your Apify API token in the connector settings to skip OAuth.\n4. In a Cowork chat, confirm the tool is available and ask it to run the Baidu API.\n\nDownload the desktop app and start a free trial: https://claude.ai/referral/uIlpa7nPLg\nMore help: https://docs.apify.com/platform/integrations/claude-desktop\n\n## Install in Claude Code\n\n![Install in Claude Code](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_code.png)\n\nClaude Code is the command-line tool. Add the Actor's MCP server with one command:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\"\n```\n\nTo use a token instead of browser OAuth:\n\n```bash\nclaude mcp add --transport http apify \\\n  \"https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\" \\\n  --header \"Authorization: Bearer YOUR_APIFY_TOKEN\"\n```\n\nThen verify with `claude mcp list`, or run `/mcp` inside a session. Ask Claude Code to call the Baidu API.\n\nTry Claude Code free: https://claude.ai/referral/uIlpa7nPLg\nClaude Code MCP docs: https://code.claude.com/docs/en/mcp\n\n## Install in Claude (website)\n\n![Install in Claude (website)](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_claude_ai.png)\n\nOn claude.ai you add Apify as a connector, then enable just this Actor's tool.\n\n1. Go to **Settings → Connectors → Browse connectors** and search for **Apify MCP server**. Install it (enable or update if prompted).\n2. When connecting, authenticate with your Apify API token, and enable the tool `johnvc/Baidu-Search-Scraper`.\n3. In any chat, open **+ → Connectors** and turn on **Apify**.\n4. Alternatively, choose **Add custom connector** and paste the full MCP URL `https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper`, using OAuth when prompted.\n5. Ask Claude to run the Baidu API.\n\nOpen Claude on the web: https://claude.ai/referral/uIlpa7nPLg\n\n## Install in Cursor\n\n![Install in Cursor](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_cursor.png)\n\nCursor reads MCP servers from a project file at `.cursor/mcp.json`.\n\n1. In your project, create `.cursor/mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\"\n    }\n  }\n}\n```\n\n2. If you prefer token auth over browser OAuth, add a header:\n\n```json\n{\n  \"mcpServers\": {\n    \"apify\": {\n      \"url\": \"https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper\",\n      \"headers\": { \"Authorization\": \"Bearer YOUR_APIFY_TOKEN\" }\n    }\n  }\n}\n```\n\n3. Open **Cursor → Settings → MCP** and confirm the **apify** server is connected (green dot).\n4. In Composer or Chat, ask Cursor to call the Baidu API.\n\nNew to Cursor? Get it here: https://cursor.com/referral?code=XQP4VBLI3NNX\n\n## Install in ChatGPT\n\n![Install in ChatGPT](https://raw.githubusercontent.com/johnisanerd/ApifyPublicData/main/assets/guides/install_mcp_into_ChatGPT.png)\n\nChatGPT connects to the Apify MCP server through Developer mode (available on ChatGPT Pro, Plus, Business, Enterprise, and Education plans).\n\n1. Click your profile icon, then go to **Settings > Apps**. If you do not see a **Create app** button, open **Advanced settings** and enable **Developer mode**.\n2. Click **Create app** and fill out the form:\n   - **Name:** Apify\n   - **MCP Server URL:** `https://mcp.apify.com/?tools=actors,docs,johnvc/Baidu-Search-Scraper`\n   - **Authentication:** OAuth\n3. Click **Create** and authorize the connection with Apify.\n4. To use the app in a conversation, click **+** in the chat, choose **Developer mode**, and select **Apify**.\n\nMore help: https://docs.apify.com/platform/integrations/mcp\n\n---\n\n[**Made with care**](https://apify.com/johnvc?fpr=9n7kx3)\n\n*Use the Baidu API to power your search and SEO workflows with reliable, structured results.*\n\n## Featured Tasks\n\nReady-to-run examples on the Apify Store.\n\n- [Export Baidu Search Results to CSV](https://apify.com/johnvc/baidu-search-scraper/examples/export-baidu-search-results-to-csv?fpr=9n7kx3)\n\nLast Updated: 2026.09.07\n",
  "bytes": 12556,
  "sha": "e031901ff6a5f08fbc116d91a97223c8f4f7fffb4f5bf9ea531758431053016c",
  "repo_slug": "johnisanerd/apify-baidu-search-scraper",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_johnisanerd_baidu_search_6febd690/readme"
}