某些网站 (列如头条,列如这篇文章本身)中会含有一些特殊的`script`数据,如
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type":"NewsArticle",
"mainEntityOfPage":
{
"@type":"WebPage",
"@id":"https://www.toutiao.com/article/7327622079795479075/"
},
"headline":"Python进阶: yield 与 yield from",
"description":"在Python中,`yield`和`yield from`都是用于生成器的关键字,但它们的用途有所不同。`yield`用于使函数成为一个生成器。",
"image":[],
"datePublished":"2024-01-24T11:41:23.000Z",
"dateModified":"2024-01-26T02:09:47.000Z",
"author":
{"@type":"Person",
"name":"闻道蜉蝣",
"url":"https://www.toutiao.com/c/user/token/MS4wLjABAAAAVNpCtqcaapt4ggrh2urUAYi5qrRBwIUo1oHl7EvQxgc/"
},
"publisher":
{
"@type":"Organization",
"name":"今日头条",
"logo":
{
"@type":"ImageObject",
"url":"https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupkbps/216.png"
}
}
}</script>
这种标识为`application/ld+json`数据叫做 JSON-LD (JSON for Linking Data)。 意为 “用于链接数据的 JSON”。在其官方网站 [1] 中,它这样描述自己的愿景:
JSON-LD is a lightweight Linked Data format. It is easy for humans to read and write. It is based on the already successful JSON format and provides a way to help JSON data interoperate at Web-scale. JSON-LD is an ideal data format for programming environments, REST Web services, and unstructured databases such as CouchDB and MongoDB.
Linked Data empowers people that publish and use information on the Web. It is a way to create a network of standards-based, machine-readable data across Web sites. It allows an application to start at one piece of Linked Data, and follow embedded links to other pieces of Linked Data that are hosted on different sites across the Web.
试翻译如下:
> JSON-LD 是一种轻量级的链接数据格式。它易于人类阅读和编写。它基于已经成功的 JSON 格式,并提供了一种协助 JSON 数据在 Web 规模上进行互操作的方法。JSON-LD 是编程环境、REST Web 服务和非结构化数据库(如 CouchDB 和 MongoDB)的理想数据格式。
> 链接数据赋予了发布和使用 Web 上的信息的人们能力。它是一种在 Web 站点之间创建基于标准的、机器可读数据网络的方法。它允许应用程序从一个链接数据开始,并跟随嵌入的链接到其他链接数据,这些链接数据托管在 Web 上的不同站点上。
schema.org
JSON-LD 的背后是 schema.org [2] 。
在 上文的 JSON-LD 样例中,主体的类型是 `NewsArticle` 。`author` 的类型是 `Person`。 这些实体都是由 schema.org 定义的。列如:https://schema.org/Person

Person
它的官方网站 [2] 中这样描述自己:
> Schema.org is a collaborative, community activity with a mission to create, maintain, and promote schemas for structured data on the Internet, on web pages, in email messages, and beyond.
> Schema.org 是一个协作的、社区活动,其使命是在互联网上、在网页上、在电子邮件中以及其他地方创建、维护和推广**结构化数据**的模式。
Schema.org 由 Google、Microsoft、Yahoo 和 Yandex 共同维护,旨在创建和支持一套通用的结构化数据标记,这些标记可以被搜索引擎和其他应用程序用于理解网页的内容。
Schema.org 提供了一套广泛的类别和属性,用于描述各种实体和关系。这些实体包括人、地点、事件、产品、组织等,而关系则包括所有这些实体之间的各种连接,如作者、制造商、位置等。对于每一个实体, Schema.org 都提供了一套属性,并且详细定义了每个属性的含义、字段类型和标准值。
Schema.org 背后是巨头们把互联网变成结构化数据的宏愿 [3] 。但这无疑是一项巴别塔一样的工作~
## ref
[1] https://json-ld.org/
[2] https://schema.org/
[3] https://developers.google.com/search/docs/guides/intro-structured-data


