Skip to main content
AI Studio  add-on for Spider.
baidu.com

Baidu Scraper

Extract Baidu search results, knowledge panels, and Chinese-language SERP data programmatically.

No key required
curl -X POST https://api.spider.cloud/scrape \
  -H "Content-Type: application/json" \
  -d '{"url": "https://developer.baidu.com/article/detail.html?id=5327212", "return_format": "markdown"}'

This exact call produced the response beside it. Get a key →

Content
367 lines 14.6 KB markdown
Render
No browser plain request is enough
Fetch time
6.8 s one measured fetch
This fetch cost
$0.000462 bandwidth plus compute
Java调用百度搜索API的完整实现指南-百度开发者中心 https://developer.baidu.com/article/detail.html?id=5327212
### 开发者热搜
3. `<artifactId>httpclient</artifactId>`
7. `<groupId>com.fasterxml.jackson.core</groupId>`
8. `<artifactId>jackson-databind</artifactId>`
### 2. 认证配置
2. `import javax.crypto.spec.SecretKeySpec;`
6. `private static final String ALGORITHM = "HmacSHA256";`
8. `public static String generateSign(String secretKey, String data) {`
10. `Mac mac = Mac.getInstance(ALGORITHM);`
11. `SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), ALGORITHM);`
13. `byte[] hash = mac.doFinal(data.getBytes());`
14. `return Base64.getEncoder().encodeToString(hash);`
16. `throw new RuntimeException("Signature generation failed", e);`
## 三、核心实现步骤
### 1. 请求构建与发送
1. `import org.apache.http.client.methods.HttpGet;`
2. `import org.apache.http.impl.client.CloseableHttpClient;`
3. `import org.apache.http.impl.client.HttpClients;`
4. `import org.apache.http.util.EntityUtils;`
6. `public class BaiduSearchClient {`
7. `private static final String BASE_URL = "https://api.baidu.com/search/v1";`
11. `public BaiduSearchClient(String apiKey, String secretKey) {`
13. `this.secretKey = secretKey;`
16. `public String search(String query, int page, int size) throws Exception {`
17. `String timestamp = String.valueOf(System.currentTimeMillis());`
18. `String signData = apiKey + query + page + size + timestamp;`
19. `String sign = AuthUtil.generateSign(secretKey, signData);`
21. `String url = BASE_URL + "?q=" + URLEncoder.encode(query, "UTF-8")`
28. `try (CloseableHttpClient client = HttpClients.createDefault()) {`
29. `HttpGet request = new HttpGet(url);`
30. `return client.execute(request, httpResponse -> `
31. `EntityUtils.toString(httpResponse.getEntity()));`
HTTP 200

You just saw the output.

That was one page. A key runs the same call across every URL on baidu.com, with browser rendering, proxies, and concurrency. Sign up and a free balance lands on your account. No card required to test.

  • Free balance on signup, no card
  • Failed requests cost $0
  • robots.txt respected by default

The same call, in code.

The keyless call above returns markdown. These examples add a key, so you get browser rendering, proxies, and concurrency on baidu.com.

baidu-scraper.ts
import { SpiderBrowser } from "spider-browser";

const spider = new SpiderBrowser({
  apiKey: process.env.SPIDER_API_KEY!,
});

await spider.connect();
const page = spider.page!;
await page.goto("https://www.baidu.com/s?wd=web+scraping");

// No selectors, no schema. Spider reads the page and names the fields.
const data = await page.scrape();

console.log(data);
await spider.close();
ready to run · spider-browser, no selectors

Ready for volume? Get an API key →

Fields you can pull.

Result titleURLSnippetPositionKnowledge panelRelated searchesDateSource

Spider names these from the page. The capture above came back as markdown; the same call with return_format: "json" returns them as keys.

What baidu.com costs to scrape.

The capture above cost $0.000462 to fetch. Pricing is $1 per GB of pre-transformation bandwidth plus $0.001 per CPU minute, so a page like this one lands at a fraction of a cent. Failed requests are billed at $0.

  • Free balance on signup
  • No card required to test
  • Balance never expires
See the full pricing →

More Search scrapers.

Start scraping baidu.com.

You already have the call. A key raises the rate limit and turns on browser rendering, proxies, and concurrency. Balance never expires, and top-ups go through secure checkout.