Google SERP API 对接说明

0 阅读20分钟

Google SERP(Search Engine Results Page)是用户在Google搜索引擎中输入查询后看到的结果页面。它显示自然搜索结果、广告、特色摘要、知识图谱以及图片、视频等多种内容,旨在为用户提供最相关的信息。

本文将详细介绍 Google SERP API,它可以提供在Google搜索引擎中输入查询获取结果,结果的内容也是包含了许多类型,比如特色摘要、知识图谱以及图片等多种结果。

本文档会介绍下 Google SERP API 的对接说明。

申请流程

要使用 Google SERP API,需要先到 Google SERP API 对应页面申请对应的服务,进入页面之后,点击「Acquire」按钮,如图所示:

如果你尚未登录或注册,会自动跳转到登录页面邀请您来注册和登录,登录注册之后会自动返回当前页面。

在首次申请时会有免费额度赠送,可以免费使用该 API。

基本使用

首先先了解下基本的使用方式,就是输入搜索关键词,就能获得搜索结果,只需要简单地传递一个 query 字段,并指定相应模型即可。

比如说询问:“apple inc”,我们接下来就可以在界面上填写对应的内容,如图所示:

可以看到这里我们设置了 Request Headers,包括:

  • accept:想要接收怎样格式的响应结果,这里填写为 application/json,即 JSON 格式。
  • authorization:调用 API 的密钥,申请之后可以直接下拉选择。

另外设置了 Request Body,包括:

  • action:搜索资源的类型,目前只支持六种类型,默认是 search
  • query:搜索的关键词。
  • country:自定义搜索结果的所在国家,默认是美国(US)。
  • language:自定义搜索结果的语言,默认是英语(en)。
  • range:自定义搜索结果的时间范围,默认是没有限制的。
  • number:自定义搜索结果的分页页面大小,默认是10。
  • page:自定义搜索结果的分页页数,默认是1。

选择之后,可以发现右侧也生成了对应代码,如图所示:

点击「Try」按钮即可进行测试,如上图所示,这里我们就得到了如下结果:

{
  "knowledge_graph": {
    "title": "Apple",
    "type": "Technology company",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
    "description": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
    "description_source": "Wikipedia",
    "description_link": "https://en.wikipedia.org/wiki/Apple_Inc.",
    "attributes": {
      "Customer service": "1 (800) 275-2273",
      "Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
      "Headquarters": "Cupertino, CA",
      "COO": "Jeff Williams",
      "CEO": "Tim Cook (Aug 24, 2011–)",
      "Founded": "April 1, 1976, Los Altos, CA"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        },
        {
          "title": "Careers at Apple",
          "link": "https://www.apple.com/careers/us/"
        },
        {
          "title": "iPhone",
          "link": "https://www.apple.com/iphone/?section-banner-soip-suerte"
        },
        {
          "title": "Mac",
          "link": "https://www.apple.com/mac/"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "List of Apple products",
          "link": "https://en.wikipedia.org/wiki/List_of_Apple_products"
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 3
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 4
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 5
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 6
    },
    {
      "title": "Apple | AAPL Stock Price, Company Overview & News - Forbes",
      "link": "https://www.forbes.com/companies/apple/",
      "snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other variety of ...",
      "position": 7
    }
  ],
  "people_also_ask": [
    {
      "question": "What is Apple Inc stand for?",
      "snippet": "It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers, including the Apple II , saw significant momentum and revenue growth for the company. \"Inc.\" is the abbreviation for incorporated. A corporation is a separate legal entity from the person or people forming it.",
      "title": "What does the 'Inc.' in Apple Inc. mean? - Quora",
      "link": "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean"
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "Macintosh"
    },
    {
      "query": "Apple Inc full form"
    },
    {
      "query": "Apple company history"
    },
    {
      "query": "Apple company owner"
    },
    {
      "query": "Apple Store"
    },
    {
      "query": "Apple Inc careers"
    },
    {
      "query": "Apple us"
    },
    {
      "query": "Apple Inc address"
    },
    {
      "query": "Apple Inc website"
    }
  ],
  "credits": 1
}

返回结果一共有多个字段,介绍如下:

  • knowledge_graph,搜索结果的知识图谱。
  • organic,搜索结果的详细信息。
  • people_also_ask,跟搜索关键词相关的问题。
  • related_searches,对于搜素关键词的相关搜索。

可以看到,这里返回的结果中有一个 organic 字段,它主要包含了搜索关键词的结果。

另外如果想生成对应的对接代码,可以直接复制生成,例如 CURL 的代码如下:

curl -X POST 'https://api.acedata.cloud/serp/google' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "query": "apple inc"
}'

Python 的对接代码如下:

import requests

url = "https://api.acedata.cloud/serp/google"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "query": "apple inc"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

自定义搜索类型

如果您自定义搜索资源的类型,我们可以修改参数 action,它分别包含了普通资源 search、图片资源 images、新闻资源 news、地图资源 maps、地区资源 places、视频资源 videos,本文将以视频资源 videos 做一个示范。

下面我们来演示下具体的操作。

首先,将 action 参数设置为 videos,并正常传递 query 参数,如图所示:

对应代码如下:

curl -X POST 'https://api.acedata.cloud/serp/google' \
-H 'accept: application/json' \
-H 'authorization: Bearer 018e9d5864524c0fb3ef725c676a0daa' \
-H 'content-type: application/json' \
-d '{
  "action": "videos",
  "query": "apple inc"
}'

可以得到如下回答:

{
  "knowledge_graph": {
    "title": "Apple",
    "type": "Technology company",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
    "description": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
    "description_source": "Wikipedia",
    "description_link": "https://en.wikipedia.org/wiki/Apple_Inc.",
    "attributes": {
      "Customer service": "1 (800) 275-2273",
      "Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
      "Headquarters": "Cupertino, CA",
      "COO": "Jeff Williams",
      "CEO": "Tim Cook (Aug 24, 2011–)",
      "Founded": "April 1, 1976, Los Altos, CA"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        },
        {
          "title": "Careers at Apple",
          "link": "https://www.apple.com/careers/us/"
        },
        {
          "title": "Mac",
          "link": "https://www.apple.com/mac/"
        },
        {
          "title": "Business",
          "link": "https://www.apple.com/business/"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "List of Apple products",
          "link": "https://en.wikipedia.org/wiki/List_of_Apple_products"
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 3
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 4
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 5
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 6
    },
    {
      "title": "Apple | AAPL Stock Price, Company Overview & News - Forbes",
      "link": "https://www.forbes.com/companies/apple/",
      "snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other variety of ...",
      "position": 7
    }
  ],
  "places": [
    {
      "title": "Apple Inc.",
      "address": "Austin, TX",
      "cid": "6364221923344007436"
    },
    {
      "title": "Apple Lonestar Design Center",
      "address": "West Lake Hills, TX",
      "cid": "96664910012456098"
    },
    {
      "title": "Apple Barton Creek",
      "address": "Austin, TX",
      "cid": "10695409311125452147"
    }
  ],
  "people_also_ask": [
    {
      "question": "What is Apple Inc stand for?",
      "snippet": "It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers, including the Apple II , saw significant momentum and revenue growth for the company. \"Inc.\" is the abbreviation for incorporated. A corporation is a separate legal entity from the person or people forming it.",
      "title": "What does the 'Inc.' in Apple Inc. mean? - Quora",
      "link": "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean"
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "Macintosh"
    },
    {
      "query": "Apple Inc full form"
    },
    {
      "query": "Apple company history"
    },
    {
      "query": "Apple company owner"
    },
    {
      "query": "Apple Store"
    },
    {
      "query": "Apple Inc careers"
    },
    {
      "query": "Apple us"
    },
    {
      "query": "Apple Inc address"
    },
    {
      "query": "Apple Inc website"
    }
  ],
  "credits": 1
}

可以看到,得到的结果与上文类似。

自定义搜索资源所在国家

该接口也支持限定搜索结果的所在国家,我们可以添加 country 参数来限定国家,输入的参数为国家的简写,比如cn(China)、us(United States),本文将以China做如下示例,下面为具体的信息:

输出效果如下:

{
  "knowledge_graph": {
    "title": "Apple",
    "type": "Technology company",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
    "description": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
    "description_source": "Wikipedia",
    "description_link": "https://en.wikipedia.org/wiki/Apple_Inc.",
    "attributes": {
      "Customer service": "400 666 8800",
      "Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
      "Headquarters": "Cupertino, California, United States",
      "COO": "Jeff Williams",
      "CEO": "Tim Cook (Aug 24, 2011–)",
      "Founded": "April 1, 1976, Los Altos, California, United States"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Business",
          "link": "https://www.apple.com/business/"
        },
        {
          "title": "India",
          "link": "https://www.apple.com/in/"
        },
        {
          "title": "Apple UK",
          "link": "https://www.apple.com/uk/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        },
        {
          "title": "Apple Watch",
          "link": "https://en.wikipedia.org/wiki/Apple_Watch"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 3
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 4
    },
    {
      "title": "Apple (中国大陆) - 官方网站",
      "link": "https://www.apple.com.cn/",
      "snippet": "探索Apple 的创新世界,选购各式iPhone、iPad、Apple Watch 和Mac,浏览各类配件、娱乐产品,并获得相关产品的专家服务支持。",
      "position": 5
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 6
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 7
    }
  ],
  "people_also_ask": [
    {
      "question": "What is the Apple Inc?",
      "snippet": "Apple Inc., originally Apple Computer, Inc., is a multinational corporation that creates and markets consumer electronics and attendant computer software, and is a digital distributor of media content. Apple's core product lines are the iPhone smartphone, iPad tablet computer, and the Macintosh personal computer.",
      "title": "History of Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "Apple Inc full form"
    },
    {
      "query": "Apple company history"
    },
    {
      "query": "Apple company owner"
    },
    {
      "query": "Apple Store"
    },
    {
      "query": "Apple us"
    },
    {
      "query": "Apple Inc address"
    },
    {
      "query": "Apple Inc website"
    },
    {
      "query": "Apple Inc headquarters"
    }
  ],
  "credits": 1
}

可以看到,结果中是在China国家的搜索结果,具体的内容与上文是类似的。

自定义搜索结果语言

我们还可以自定义搜索结果的语言,这里我们额外添加 language 字段,内容为 zh-cn,其中它指的是简体中文的语言,同时还支持其他语言,但必须输入的语言的简写,比如en(English)、fr(French)、zh-cn(Chinese(Simplified))等语言,如图所示:

对应代码如下:

curl -X POST 'https://api.acedata.cloud/serp/google' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "query": "apple inc",
  "language": "zh-cn"
}'

运行结果如下:

{
  "knowledge_graph": {
    "title": "苹果",
    "type": "公司",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRgbY1KzXEpuPeTpcw0GwN6BpQTcg1m06TDUsfdG6P-zW3eWrmu78AXyg&s=0",
    "attributes": {
      "创始人": "史蒂夫·乔布斯、史蒂夫·沃兹尼亚克和罗纳德·韦恩",
      "创立于": "1976 年 4 月 1 日,加利福尼亚洛思阿图斯",
      "总部": "加利福尼亚库比蒂诺"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Careers at Apple",
          "link": "https://www.apple.com/careers/us/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        },
        {
          "title": "Business",
          "link": "https://www.apple.com/business/"
        },
        {
          "title": "Apple UK",
          "link": "https://www.apple.com/uk/"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        },
        {
          "title": "Apple Watch",
          "link": "https://en.wikipedia.org/wiki/Apple_Watch"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 3
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 4
    },
    {
      "title": "Apple Inc. (AAPL) Stock Price, News, Quote & History - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide.",
      "date": "2024年8月27日",
      "position": 5
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 6
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 7
    }
  ],
  "people_also_ask": [
    {
      "question": "What is Apple Inc stand for?",
      "snippet": "It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers, including the Apple II , saw significant momentum and revenue growth for the company. \"Inc.\" is the abbreviation for incorporated. A corporation is a separate legal entity from the person or people forming it.",
      "title": "What does the 'Inc.' in Apple Inc. mean? - Quora",
      "link": "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean"
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "apple inc是什么"
    },
    {
      "query": "apple澳门"
    },
    {
      "query": "Apple ID"
    },
    {
      "query": "apple美国"
    },
    {
      "query": "apple官网"
    },
    {
      "query": "apple美国官网"
    },
    {
      "query": "Apple company introduction"
    },
    {
      "query": "apple id官网"
    }
  ],
  "credits": 1
}

可以看到这里显示的结果都是简体中文的语言,结果的内容与上文类似。

自定义搜索结果时间范围

本文还可以自定义搜索结果的时间范围,包括了五种,分别是 qdr:h(过去一个小时)、qdr:d(过去一天)、qdr:w(过去一周)、qdr:m(过去一个月)、默认无限制,我们可以通过 range 传递对应的时间范围即可,比如这里设置为 qdr:d,这样表示搜索过去一天的结果,所以输入如下:

对应的代码如下:

curl -X POST 'https://api.acedata.cloud/serp/google' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "range": "qdr:d",
  "query": "apple inc"
}'

运行结果如下:

{
  "knowledge_graph": {
    "title": "Apple",
    "type": "Technology company",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
    "description": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
    "description_source": "Wikipedia",
    "description_link": "https://en.wikipedia.org/wiki/Apple_Inc.",
    "attributes": {
      "Customer service": "1 (800) 275-2273",
      "Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
      "Headquarters": "Cupertino, CA",
      "COO": "Jeff Williams",
      "CEO": "Tim Cook (Aug 24, 2011–)",
      "Founded": "April 1, 1976, Los Altos, CA"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        },
        {
          "title": "Careers at Apple",
          "link": "https://www.apple.com/careers/us/"
        },
        {
          "title": "Mac",
          "link": "https://www.apple.com/mac/"
        },
        {
          "title": "Business",
          "link": "https://www.apple.com/business/"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "List of Apple products",
          "link": "https://en.wikipedia.org/wiki/List_of_Apple_products"
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 3
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 4
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 5
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 6
    },
    {
      "title": "Apple | AAPL Stock Price, Company Overview & News - Forbes",
      "link": "https://www.forbes.com/companies/apple/",
      "snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other variety of ...",
      "position": 7
    }
  ],
  "places": [
    {
      "title": "Apple Inc.",
      "address": "Austin, TX",
      "cid": "6364221923344007436"
    },
    {
      "title": "Apple Lonestar Design Center",
      "address": "West Lake Hills, TX",
      "cid": "96664910012456098"
    },
    {
      "title": "Apple The Summit",
      "address": "Birmingham, AL",
      "cid": "15135424056620472574"
    }
  ],
  "people_also_ask": [
    {
      "question": "What is Apple Inc stand for?",
      "snippet": "It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers, including the Apple II , saw significant momentum and revenue growth for the company. \"Inc.\" is the abbreviation for incorporated. A corporation is a separate legal entity from the person or people forming it.",
      "title": "What does the 'Inc.' in Apple Inc. mean? - Quora",
      "link": "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean"
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "Macintosh"
    },
    {
      "query": "Apple Inc full form"
    },
    {
      "query": "Apple company history"
    },
    {
      "query": "Apple company owner"
    },
    {
      "query": "Apple Store"
    },
    {
      "query": "Apple Inc careers"
    },
    {
      "query": "Apple Inc address"
    },
    {
      "query": "Apple us"
    },
    {
      "query": "Apple Inc website"
    }
  ],
  "credits": 1
}

可以看到,我们就成功得到了过去一天的搜索结果,结果内容与上文类似。

自定义搜索结果分页

本API还支持自定义搜索结果的分页展示,numberpage 表示分页的页面大小和页数,本文将设置一页里面有20个搜索结果的形式来进行分页展示,具体的信息如图所示:

代码如下:

curl -X POST 'https://api.acedata.cloud/serp/google' \
-H 'accept: application/json' \
-H 'authorization: Bearer 018e9d5864524c0fb3ef725c676a0daa' \
-H 'content-type: application/json' \
-d '{
  "query": "apple inc",
  "number": 20,
  "page": 1
}'

运行结果如下:

{
  "knowledge_graph": {
    "title": "Apple",
    "type": "Technology company",
    "website": "http://www.apple.com/",
    "image_url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0",
    "description": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley. It is best known for its consumer electronics, software, and services.",
    "description_source": "Wikipedia",
    "description_link": "https://en.wikipedia.org/wiki/Apple_Inc.",
    "attributes": {
      "Customer service": "1 (800) 275-2273",
      "Founders": "Steve Jobs, Steve Wozniak, and Ronald Wayne",
      "Headquarters": "Cupertino, CA",
      "COO": "Jeff Williams",
      "CEO": "Tim Cook (Aug 24, 2011–)",
      "Founded": "April 1, 1976, Los Altos, CA"
    }
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "snippet": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, ...",
      "sitelinks": [
        {
          "title": "Support",
          "link": "https://support.apple.com/"
        },
        {
          "title": "Store",
          "link": "https://www.apple.com/store"
        },
        {
          "title": "Careers at Apple",
          "link": "https://www.apple.com/careers/us/"
        },
        {
          "title": "Mac",
          "link": "https://www.apple.com/mac/"
        },
        {
          "title": "Business",
          "link": "https://www.apple.com/business/"
        }
      ],
      "position": 1
    },
    {
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc.",
      "snippet": "Apple Inc. is an American multinational corporation and technology company headquartered in Cupertino, California, in Silicon Valley.",
      "sitelinks": [
        {
          "title": "History",
          "link": "https://en.wikipedia.org/wiki/History_of_Apple_Inc."
        },
        {
          "title": "List of Apple products",
          "link": "https://en.wikipedia.org/wiki/List_of_Apple_products"
        },
        {
          "title": "Litigation involving Apple Inc.",
          "link": "https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc."
        },
        {
          "title": "Apple Park",
          "link": "https://en.wikipedia.org/wiki/Apple_Park"
        }
      ],
      "position": 2
    },
    {
      "title": "Apple Inc. (AAPL) Company Profile & Facts - Yahoo Finance",
      "link": "https://finance.yahoo.com/quote/AAPL/profile/",
      "snippet": "See the company profile for Apple Inc. (AAPL) including business summary, industry/sector information, number of employees, business summary, ...",
      "position": 3
    },
    {
      "title": "Apple Inc. | History, Products, Headquarters, & Facts - Britannica",
      "link": "https://www.britannica.com/money/Apple-Inc",
      "snippet": "Apple Inc. is an American multinational technology company that revolutionized the technology sector through its innovation of computer software, ...",
      "position": 4
    },
    {
      "title": "Apple Inc - Company Profile and News - Bloomberg Markets",
      "link": "https://www.bloomberg.com/profile/company/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related ...",
      "position": 5
    },
    {
      "title": "AAPL: Apple Inc Stock Price Quote - NASDAQ GS - Bloomberg",
      "link": "https://www.bloomberg.com/quote/AAPL:US",
      "snippet": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related accessories.",
      "position": 6
    },
    {
      "title": "Apple | AAPL Stock Price, Company Overview & News - Forbes",
      "link": "https://www.forbes.com/companies/apple/",
      "snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other variety of ...",
      "position": 7
    },
    {
      "title": "Apple Inc. Stock Quote (U.S.: Nasdaq) - AAPL - MarketWatch",
      "link": "https://www.marketwatch.com/investing/stock/aapl",
      "snippet": "Apple, Inc. engages in the design, manufacture, and sale of smartphones, personal computers, tablets, wearables and accessories, and other varieties of related ...",
      "position": 8
    },
    {
      "title": "Apple - LinkedIn",
      "link": "https://www.linkedin.com/company/apple",
      "snippet": "Apple | 17585634 followers on LinkedIn. We're a diverse collective of ... Company size: 10,001+ employees. Headquarters: Cupertino, California. Type ...",
      "position": 9
    },
    {
      "title": "Android Apps by Apple Inc. on Google Play",
      "link": "https://play.google.com/store/apps/developer?id=Apple+Inc.&hl=en_US",
      "snippet": "Enjoy millions of the latest Android apps, games, music, movies, TV, books, magazines & more. Anytime, anywhere, across your devices.",
      "position": 10
    },
    {
      "title": "Apple - X",
      "link": "https://twitter.com/apple",
      "snippet": "... co/4dZx1rwvgY. ... @Apple hasn't posted. When they do, their posts will show up here.",
      "position": 11
    },
    {
      "title": "Apple Inc Company Profile - Apple Inc Overview - GlobalData",
      "link": "https://www.globaldata.com/company-profile/apple-inc/",
      "snippet": "Related keylists ... Apple Inc (Apple) designs, manufactures, and markets smartphones, tablets, personal computers, and wearable devices. The company offers ...",
      "position": 12
    },
    {
      "title": "AAPL.O - Apple Inc - Reuters",
      "link": "https://www.reuters.com/markets/companies/AAPL.O",
      "snippet": "Apple Inc. designs, manufactures and markets smartphones, personal computers, tablets, wearables and accessories, and sells a variety of related services.",
      "position": 13
    },
    {
      "title": "Apple (AAPL) Stock Price, Quote, News & History | Nasdaq",
      "link": "https://www.nasdaq.com/market-activity/stocks/aapl",
      "snippet": "Discover real-time Apple Inc. Common Stock (AAPL) stock prices, quotes, historical data, news, and Insights for informed trading and investment decisions.",
      "position": 14
    },
    {
      "title": "Apple Inc (AAPL) Stock Price & News - Google Finance",
      "link": "https://www.google.com/finance/quote/AAPL:NASDAQ?hl=en",
      "snippet": "Get the latest Apple Inc (AAPL) real-time quote, historical performance, charts, and other financial information to help you make more informed trading and ...",
      "currency": "$",
      "price": 222.34,
      "position": 15
    },
    {
      "title": "AAPL: Apple Inc - Stock Price, Quote and News - CNBC",
      "link": "https://www.cnbc.com/quotes/AAPL",
      "snippet": "Get Apple Inc (AAPL:NASDAQ) real-time stock quotes, news, price and financial information from CNBC.",
      "position": 16
    },
    {
      "title": "Apple Inc. - AnnualReports.com",
      "link": "https://www.annualreports.com/Company/apple-inc",
      "snippet": "Most Recent Annual Report. Apple Inc. ... Apple Inc. does not currently have any hardcopy reports on AnnualReports.com. Click the button below to request a report ...",
      "position": 17
    }
  ],
  "people_also_ask": [
    {
      "question": "What is Apple Inc stand for?",
      "snippet": "It was incorporated as Apple Computer, Inc. in January 1977, and sales of its computers, including the Apple II , saw significant momentum and revenue growth for the company. \"Inc.\" is the abbreviation for incorporated. A corporation is a separate legal entity from the person or people forming it.",
      "title": "What does the 'Inc.' in Apple Inc. mean? - Quora",
      "link": "https://www.quora.com/What-does-the-Inc-in-Apple-Inc-mean"
    },
    {
      "question": "Who owns Apple Inc.?",
      "snippet": "Apple (AAPL) Ownership Overview The ownership structure of Apple (AAPL) stock is a mix of institutional, retail and individual investors. Approximately 48.76% of the company's stock is owned by Institutional Investors, 0.11% is owned by Insiders and 51.13% is owned by Public Companies and Individual Investors.",
      "title": "Who owns Apple? AAPL Stock Ownership - TipRanks.com",
      "link": "https://www.tipranks.com/stocks/aapl/ownership"
    },
    {
      "question": "Why did Apple change to Apple Inc?",
      "snippet": "During his keynote speech at the Macworld Expo on January 9, 2007, Jobs announced the renaming of Apple Computer, Inc. to Apple Inc., because the company had broadened its focus from computers to consumer electronics. This event also saw the announcement of the iPhone and the Apple TV.",
      "title": "Apple Inc. - Wikipedia",
      "link": "https://en.wikipedia.org/wiki/Apple_Inc."
    },
    {
      "question": "Why Apple Inc is called Apple?",
      "snippet": "With the name Apple, the new computer company would appear ahead of Atari, where Jobs used to work. Jobs confirmed this theory in an 1980 presentation, stating that the name was partly chosen because he liked apples and partly because Apple was ahead of Atari in the phone book.",
      "title": "Why Is Apple Called Apple? - Apple Scoop",
      "link": "https://applescoop.org/story/why-is-apple-called-apple"
    }
  ],
  "related_searches": [
    {
      "query": "Macintosh"
    },
    {
      "query": "Apple Inc full form"
    },
    {
      "query": "Apple company history"
    },
    {
      "query": "Apple company owner"
    },
    {
      "query": "Apple Inc careers"
    },
    {
      "query": "Apple Store"
    },
    {
      "query": "Apple Inc address"
    },
    {
      "query": "Apple us"
    },
    {
      "query": "Apple Inc website"
    }
  ],
  "credits": 2
}

可以看到,这里它对搜索结果进行了分页展示,一页里面展示了20条结果,结果的内容与上文类似。