百度百科
其他 官方文档
内容来自百度百科平台,由百度百科网友创作
基本说明:
接口地址:https://baike.baidu.com/api/openapi/BaikeLemmaCardApi
返回格式:json
请求方式:get/post
请求示例:https://baike.baidu.com/api/openapi/BaikeLemmaCardApi?appid=379020&bk_key=接口
请求参数说明:
名称 类型 必填 说明
appid int 必填 密钥 扫码关注公众号
bk_key string 必填 百度百科关键词
返回参数说明:
名称 类型 说明
- - 见json
JSON返回示例:
{
	"id": 159864,
	"subLemmaId": 15347639,
	"newLemmaId": 2886384,
	"key": "接口",
	"desc": "汉语词汇",
	"title": "接口",
	"card": [{
		"key": "m25_nameC",
		"name": "中文名",
		"value": ["接口"],
		"format": ["接口"]
	}, {
		"key": "m25_nameE",
		"name": "外文名",
		"value": ["interface"],
		"format": ["interface"]
	}, {
		"key": "m25_customDefault",
		"name": "功能",
		"value": ["沟通媒介"],
		"format": ["沟通媒介"]
	}, {
		"key": "m25_classification",
		"name": "分类",
		"value": ["硬件接口,软件接口"],
		"format": ["硬件接口,软件接口"]
	}, {
		"key": "m25_pinyin",
		"name": "拼音",
		"value": ["jiē kǒu"],
		"format": ["jiē kǒu"]
	}, {
		"key": "m25_customDefault",
		"name": "IT释义",
		"value": ["两个不同系统(或子程序)交接并通过它彼此作用的部分"],
		"format": ["两个不同系统(或子程序)交接并通过它彼此作用的部分"]
	}],
	"image": "https:\/\/bkimg.cdn.bcebos.com\/pic\/960a304e251f95ca6fa650faca177f3e6709522f?x-bce-process=image\/format,f_auto",
	"src": "960a304e251f95ca6fa650faca177f3e6709522f",
	"imageHeight": 1060,
	"imageWidth": 1319,
	"isSummaryPic": "y",
	"abstract": "接口泛指实体把自己提供给外界的一种抽象化物(可以为另一实体),用以由内部操作分离出外部沟通方法,使其能被内部修改而不影响外界其他实体与其交互的方式。人类与电脑等信息机器或人类与程序之间的接口称为用户界面。电脑等信息机器硬件组件间的接口叫硬件接口。电脑等信息机器软件组件间的接口叫软件接口。在计算机中,接口是计算机系统中两个独立的部件进行信息交换的共享边界。这种交换可以发生在计算机软、硬件,外部设备或...",
	"moduleIds": [3665222853, 3665222854, 3665222857],
	"url": "http:\/\/baike.baidu.com\/subview\/159864\/15347639.htm",
	"wapUrl": "http:\/\/wapbaike.baidu.com\/item\/接口\/2886384",
	"hasOther": 1,
	"totalUrl": "http:\/\/baike.baidu.com\/view\/159864.htm",
	"catalog": ["<a href='http:\/\/baike.baidu.com\/subview\/159864\/15347639.htm#1'>词目<\/a>", "<a href='http:\/\/baike.baidu.com\/subview\/159864\/15347639.htm#2'>拼音<\/a>", "<a href='http:\/\/baike.baidu.com\/subview\/159864\/15347639.htm#3'>词汇基本解释<\/a>", "<a href='http:\/\/baike.baidu.com\/subview\/159864\/15347639.htm#4'>引证解释<\/a>"],
	"wapCatalog": ["<a href='http:\/\/wapbaike.baidu.com\/item\/接口\/2886384#1'>词目<\/a>", "<a href='http:\/\/wapbaike.baidu.com\/item\/接口\/2886384#2'>拼音<\/a>", "<a href='http:\/\/wapbaike.baidu.com\/item\/接口\/2886384#3'>词汇基本解释<\/a>", "<a href='http:\/\/wapbaike.baidu.com\/item\/接口\/2886384#4'>引证解释<\/a>"],
	"logo": "https:\/\/img.baidu.com\/img\/baike\/logo-baike.gif",
	"copyrights": "以上内容来自百度百科平台,由百度百科网友创作。",
	"customImg": "",
	"redirect": []
}
服务级错误码参照
错误码 说明
6 密钥错误
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2022/04/08 11:38
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://baike.baidu.com/api/openapi/BaikeLemmaCardApi?appid=379020&bk_key=接口';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://baike.baidu.com/api/openapi/BaikeLemmaCardApi?appid=379020&bk_key=接口"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}