# 使用方法

以下是为**百度热搜API**编写的完整文档示例，包含接口概述、调用方式（PHP/Python/JavaScript）及响应示例：

#### 百度热搜API文档

**接口概述**

获取百度实时热搜排行榜前5条数据，返回标题、链接、热度值及排名信息。

**基础URL**

**百度：**

```
https://api.8i5.net/hot/v2/baidu.php
```

微博：

```
https://api.8i5.net/hot/v2/weibo.php
```

Bilibili:

```
https://api.8i5.net/hot/v2/bilibili.php
```

掘金：

```
https://api.8i5.net/hot/v2/juejin.php
```

豆瓣

```
https://api.8i5.net/hot/v2/douban.php
```

**请求方式**\
`GET`（无需参数）

**响应格式**\
JSON（UTF-8编码）

**调用示例**

**PHP调用**

```php
<?php
$url = 'https://api.8i5.net/hot/v2/baidu.php';
$response = file_get_contents($url);
$data = json_decode($response, true);

// 打印标题列表
foreach ($data['data'] as $item) {
    echo "排名: {$item['rank']}, 标题: {$item['title']}\n";
}
?>
```

**Python调用**

```python
import requests

url = 'https://api.8i5.net/hot/v2/baidu.php'
response = requests.get(url)
data = response.json()

# 打印标题列表
for item in data['data']:
    print(f"排名: {item['rank']}, 标题: {item['title']}")
```

**JavaScript调用（浏览器）**

```javascript
fetch('https://api.8i5.net/hot/v2/baidu.php')
  .then(response => response.json())
  .then(data => {
    // 打印标题列表
    data.data.forEach(item => {
      console.log(`排名: ${item.rank}, 标题: ${item.title}`);
    });
  })
  .catch(error => console.error('请求失败:', error));
```

**cURL命令（终端）**

```bash
curl -X GET "https://api.8i5.net/hot/v2/baidu.php"
```

**响应示例**

```json
{
  "date": "2025-05-26 14:30:00",
  "platform": "baidu",
  "data": [
    {
      "title": "示例热搜标题1",
      "url": "https://www.baidu.com/s?wd=关键词1",
      "hot": "999999",
      "rank": 1
    },
    {
      "title": "示例热搜标题2",
      "url": "https://www.baidu.com/s?wd=关键词2",
      "hot": "888888",
      "rank": 2
    },
    // 省略后续3条...
  ]
}
```

**字段说明**

| 字段         | 类型     | 描述               |
| ---------- | ------ | ---------------- |
| `date`     | string | 数据获取时间（ISO格式）    |
| `platform` | string | 平台名称（固定为`baidu`） |
| `data`     | array  | 热搜数据列表           |
| `title`    | string | 热搜标题             |
| `url`      | string | 对应的百度搜索链接        |
| `hot`      | string | 热度值（文本格式）        |
| `rank`     | int    | 排名（1-5）          |

**错误处理**

* 若请求超时或服务器错误，返回空数组`[]`
* 若解析失败（如网站结构变更），返回空数组`[]`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-doc.8i5.net/re-sou-bang/shi-yong-fang-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
