在 Google 搜索结果中展示表格

在 Google 里搜索 NBA 这个关键字,我们注意到 wikipedia 这个搜索结果里,有一部分是以表格的形式示展现

表格形式的搜索结果可以更清晰的展示网页数据


Wikipedia 是怎么做的

我们到 wikipedia 网页内相找相关代码

发现并没有对应的结构化数据,唯一和搜索结果相关的代码就是一处 table 元素

这个 table 元素里的内容和搜索结果里的 表格内容 完全一致

可以认为就是这个 table 导致了搜索结果里的表格样式


通过结构化数据实现效果

在看过实际的例子之后,又 Google 了一波 google serp table

发现是有一种“正统”的方式去做这个事情

谷歌提供了一种叫做表格数据集的结构化数据

通过配置可以实现在搜索结果里呈现表格式的样式 ( 之前的文章有介绍过结构化数据):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script type="application/ld+json">
{
"@context": ["https://schema.org", {"csvw": "http://www.w3.org/ns/csvw#"}],
"@type": "Dataset",
"name":"AMERICAN HUMANE ASSOCIATION",
"description": "ProPublica's Nonprofit Explorer lets you view summaries of 2.2 million tax returns from tax-exempt organizations and see financial details such as their executive compensation and revenue and expenses. You can browse raw IRS data released since 2013 and access over 9.4 million tax filing documents going back as far as 2001.",
"publisher": {
"@type": "Organization",
"name": "ProPublica"
},
"mainEntity" : {
"@type" : "csvw:Table",
"csvw:tableSchema": {
"csvw:columns": [
{
"csvw:name": "Year",
"csvw:datatype": "string",
"csvw:cells": [
{
"csvw:value": "2016",
"csvw:primaryKey": "2016"
},
{
"csvw:value": "2015",
"csvw:primaryKey": "2015"
}]
},
{
"csvw:name": "Organization name",
"csvw:datatype": "string",
"csvw:cells": [
{
"csvw:value": "AMERICAN HUMANE ASSOCIATION",
"csvw:primaryKey": "2016"
},
{
"csvw:value": "AMERICAN HUMANE ASSOCIATION",
"csvw:primaryKey": "2015"
}]
}]
}
}
}
</script>

不过人家也提到:

此方法目前正处于测试阶段,因此可能会发生变化。

原文作者: dgb8901,yinxing

原文链接: https://www.itwork.club/2019/09/24/table-in-google-search-result/

版权声明: 转载请注明出处

为您推荐

体验小程序「简易记账」

关注公众号「特想学英语」

根据不同环境构建 Vue 项目