Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 98 additions & 3 deletions api-reference/endpoint/baidu/search.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: "Baidu Web Search"
api: "GET https://scrapebadger.com/v1/baidu/search"
description: "Search baidu.com — organic results with the real target URL, related searches, language and publish-date filters."
description: "Search baidu.com — organic results with the real target URL, Baidu's own cards, related searches, language and publish-date filters."
---

Search `baidu.com` — the web SERP of China's #1 search engine. Every organic
result carries the **real target URL** in `url` (decoded from Baidu's `mu`
attribute), alongside the `baidu.com/link?url=` tracking redirect in
`baidu_url`.
`baidu_url`. Baidu's own cards on the page (Baike, its AI answer, images,
goods, notes ...) come back separately in [`cards`](#baidus-own-cards).

**Credits:** 5

Expand Down Expand Up @@ -79,6 +80,34 @@ attribute), alongside the `baidu.com/link?url=` tracking redirect in
<ResponseField name="tpl" type="string">Baidu's result template id, e.g. `se_com_default`, `www_index`.</ResponseField>
</Expandable>
</ResponseField>
<ResponseField name="cards" type="Card[]">
Baidu's own cards on this page, in page order. See
[Baidu's own cards](#baidus-own-cards). An empty array when the page has none.

<Expandable title="Card">
<ResponseField name="position" type="integer">
Baidu's number for the card's place on the page. Organic results and
cards share this numbering: `1`–`10` on page 1, `11`–`20` on page 2.
</ResponseField>
<ResponseField name="type" type="string">
Baidu's template name for the card, as it is in the page, e.g.
`bk_polysemy`, `new_baikan_index`, `image_grid_san`.
</ResponseField>
<ResponseField name="title" type="string">The card's heading.</ResponseField>
<ResponseField name="url" type="string">
The **real target URL** when the page gives one, otherwise the same link
as `baidu_url`.
</ResponseField>
<ResponseField name="baidu_url" type="string">
The heading's own link, usually Baidu's `baidu.com/link?url=...` tracking
redirect.
</ResponseField>
<ResponseField name="snippet" type="string">
The card's summary text, when it has one. Lists and grids (images, goods,
notes) have none.
</ResponseField>
</Expandable>
</ResponseField>
<ResponseField name="related_searches" type="RelatedSearch[]">
Baidu's query suggestions from the foot of the SERP.

Expand All @@ -91,7 +120,7 @@ attribute), alongside the `baidu.com/link?url=` tracking redirect in
<Note>
Only `position`, `title`, `query`, `page`, `num` and `url` are guaranteed
present. Every other field is nullable — Baidu's SERP renders a different
field set per result template (`tpl`).
field set per result template (`tpl`). Every field of a card is nullable.
</Note>

## Example
Expand Down Expand Up @@ -163,6 +192,32 @@ data = res.json()
"tpl": "www_index"
}
],
"cards": [
{
"position": 1,
"type": "new_baikan_index",
"title": null,
"url": null,
"baidu_url": null,
"snippet": "“咖啡机”通常指制作咖啡的家用电器,按工作方式分为滴漏式、意式半自动和全自动等。"
},
{
"position": 4,
"type": "sg_kg_entity_san",
"title": "咖啡机(自动实现酿制咖啡的机器) - 百度百科",
"url": "https://baike.baidu.com/item/%E5%92%96%E5%95%A1%E6%9C%BA/1054960",
"baidu_url": "http://www.baidu.com/link?url=WlGObndkGGpxDKmR4sVQhT",
"snippet": "咖啡机(外文名:Coffee machine)是一种通过电子技术实现自动控制的咖啡冲泡设备。"
},
{
"position": 5,
"type": "image_grid_san",
"title": "咖啡机- 百度图片",
"url": "http://image.baidu.com/search/index?tn=baiduimage&word=%E5%92%96%E5%95%A1%E6%9C%BA",
"baidu_url": "https://image.baidu.com/search/index?tn=baiduimage&word=%E5%92%96%E5%95%A1%E6%9C%BA",
"snippet": null
}
],
"related_searches": [
{
"query": "咖啡机器人多少钱一台",
Expand All @@ -181,6 +236,46 @@ data = res.json()
}
```

## Baidu's own cards

Baidu mixes its own cards with the organic results: a Baike entry, its AI
answer, an image grid, goods, notes, a map, the latest news. For a popular term
they can take **every place on page 1**, and then `results` is an empty array
while the page is full. `cards` lists them, so that page is not an empty
answer.

- **One entry per card, in page order.** Every card is read the same way,
whatever its kind: its heading, the heading's link, the real target and the
summary text. A card that has none of these is left out (the "others also
searched" box). Ads are never included.
- **`type` is Baidu's own template name**, passed through as it is. Baidu adds
and renames templates, so treat it as an open string and match the ones you
need.
- **`position` is Baidu's number for the place on the page**, and organic
results and cards share that numbering. It is **not** the same sequence as
`results[].position`, which is the rank among the organic results only. On a
page whose organic results sit at Baidu's places 5, 6 and 10, those results
have `position` 1, 2 and 3, and the cards say 1, 2, 4, 7, 8 and 9.

| `type` | Card |
| ------ | ---- |
| `new_baikan_index` | Baidu's AI answer. `snippet` is the answer's first paragraph; it often has no link. |
| `bk_polysemy`, `sg_kg_entity_san` | Baidu Baike entry. `url` is the Baike page. |
| `image_grid_san` | Image results. `url` is the image search. |
| `sp_purc_pc` | Goods. `url` is the shopping search. |
| `note_lead` | Notes. |
| `rel_base_realtime` | Latest news about the query. |
| `tieba_general` | Baidu Tieba forum. |
| `jy_xueshu_links_atom`, `jy_wenku_wenshu` | Papers and Wenku documents. |
| `mapcity`, `text01` | Map. |

These are the common ones, not a complete list.

<Tip>
To track a domain's visibility, read both lists: Baike, Tieba and Wenku pages
are Baidu properties that appear as cards, not as organic results.
</Tip>

## Pagination

<Warning>
Expand Down
5 changes: 5 additions & 0 deletions baidu/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ anywhere.
- **Web search** — organic results with `title`, real `url`, `snippet`,
`source` (the site name Baidu shows), `date`/`date_at`, `thumbnail` and
Baidu's own `tpl` template id. Up to **50 results per page**.
- **Baidu's own cards** — the Baike entry, AI answer, image grid, goods, notes
and other cards Baidu mixes into the page come back in `cards`, each with its
place on the page, Baidu's template name, heading, real `url` and summary.
For a popular term they can fill page 1, so read both lists. See
[Baidu's own cards](/api-reference/endpoint/baidu/search#baidus-own-cards).
- **Language filter** — restrict to simplified (`zh-cn`) or traditional
(`zh-tw`) Chinese, or leave it open with `all`.
- **Publish-date window** — `time_from` / `time_to` as Unix timestamps, mapped
Expand Down
Loading