microlink-google

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

@microlink/google

@microlink/google

Unified Node.js client for querying 10 Google verticals through the Microlink API. Returns normalized, structured data with pagination and lazy HTML fetching.
基于Microlink API封装的统一Node.js客户端,可查询10个谷歌垂直品类服务,返回标准化的结构化数据,支持分页和懒加载HTML获取功能。

Quick Start

快速开始

The only prerequisite to initialize @microlink/google is to have Microlink API key:
js
const google = require('@microlink/google')({
  apiKey: process.env.MICROLINK_API_KEY
})

const page = await google('Lotus Elise S2')
console.log(page.results)
The
query
string supports standard Google search operators:
js
await google('annual report filetype:pdf')
await google('security updates site:github.com')
await google('"machine learning" site:arxiv.org')
初始化@microlink/google的唯一前置条件是拥有Microlink API密钥
js
const google = require('@microlink/google')({
  apiKey: process.env.MICROLINK_API_KEY
})

const page = await google('Lotus Elise S2')
console.log(page.results)
query
字符串支持标准的谷歌搜索运算符
js
await google('annual report filetype:pdf')
await google('security updates site:github.com')
await google('"machine learning" site:arxiv.org')

Query Signature

查询签名

js
const page = await google(query, options?)
js
const page = await google(query, options?)

Options

参数选项

OptionTypeDefaultValues
type
string
'search'
search
,
news
,
images
,
videos
,
places
,
maps
,
shopping
,
scholar
,
patents
,
autocomplete
location
string
'us'
ISO 3166-1 alpha-2 country code
period
string
hour
,
day
,
week
,
month
,
year
limit
number
Results per page
参数类型默认值可选值
type
string
'search'
search
,
news
,
images
,
videos
,
places
,
maps
,
shopping
,
scholar
,
patents
,
autocomplete
location
string
'us'
ISO 3166-1 alpha-2标准国家代码
period
string
hour
,
day
,
week
,
month
,
year
limit
number
每页返回结果数

Google Products

谷歌产品支持

Google Search (default)

Google Search(默认)

js
const page = await google('node.js frameworks')
Page:
results
,
knowledgeGraph?
,
peopleAlsoAsk?
,
relatedSearches?
Result:
title
,
url
,
description
,
html()
KnowledgeGraph:
title?
,
type?
,
website?
,
image?
,
description?
,
descriptionSource?
,
descriptionLink?
,
attributes?
js
const page = await google('node.js frameworks')
页对象字段:
results
,
knowledgeGraph?
,
peopleAlsoAsk?
,
relatedSearches?
结果项字段:
title
,
url
,
description
,
html()
知识图谱字段:
title?
,
type?
,
website?
,
image?
,
description?
,
descriptionSource?
,
descriptionLink?
,
attributes?

Google News

Google News

js
const page = await google('artificial intelligence', { type: 'news' })
Result:
title
,
url
,
description
,
date
,
publisher
,
image?
,
html()
js
const page = await google('artificial intelligence', { type: 'news' })
结果项字段:
title
,
url
,
description
,
date
,
publisher
,
image?
,
html()

Google Images

Google Images

js
const page = await google('northern lights', { type: 'images' })
Result:
title
,
url
,
image { url, width, height }
,
thumbnail { url, width, height }
,
google?
,
creator?
,
credit?
,
html()
js
const page = await google('northern lights', { type: 'images' })
结果项字段:
title
,
url
,
image { url, width, height }
,
thumbnail { url, width, height }
,
google?
,
creator?
,
credit?
,
html()

Google Videos

Google Videos

js
const page = await google('cooking tutorial', { type: 'videos' })
Result:
title
,
url
,
description
,
image?
,
video?
,
duration?
,
duration_pretty?
,
publisher?
,
channel?
,
date?
,
html()
js
const page = await google('cooking tutorial', { type: 'videos' })
结果项字段:
title
,
url
,
description
,
image?
,
video?
,
duration?
,
duration_pretty?
,
publisher?
,
channel?
,
date?
,
html()

Google Places

Google Places

js
const page = await google('coffee shops denver', { type: 'places' })
Result:
title
,
address
,
latitude
,
longitude
,
phone?
,
url?
,
cid
,
html()
js
const page = await google('coffee shops denver', { type: 'places' })
结果项字段:
title
,
address
,
latitude
,
longitude
,
phone?
,
url?
,
cid
,
html()

Google Maps

Google Maps

js
const page = await google('apple store new york', { type: 'maps' })
Result:
title
,
address
,
latitude
,
longitude
,
rating?
,
ratingCount?
,
price? { level }
,
type?
,
types?
,
url?
,
phone?
,
description?
,
opening?
,
thumbnail?
,
cid
,
fid?
,
place?
,
html()
js
const page = await google('apple store new york', { type: 'maps' })
结果项字段:
title
,
address
,
latitude
,
longitude
,
rating?
,
ratingCount?
,
price? { level }
,
type?
,
types?
,
url?
,
phone?
,
description?
,
opening?
,
thumbnail?
,
cid
,
fid?
,
place?
,
html()

Google Shopping

Google Shopping

js
const page = await google('macbook pro', { type: 'shopping' })
Result:
title
,
url
,
publisher
,
price { symbol, amount }
,
image?
,
rating? { score, total, reviews? }
,
id?
,
html()
js
const page = await google('macbook pro', { type: 'shopping' })
结果项字段:
title
,
url
,
publisher
,
price { symbol, amount }
,
image?
,
rating? { score, total, reviews? }
,
id?
,
html()

Google Scholar

Google Scholar

js
const page = await google('transformer architecture', { type: 'scholar' })
Result:
title
,
url
,
description
,
publisher
,
year
,
citations
,
pdf?
,
id
,
html()
js
const page = await google('transformer architecture', { type: 'scholar' })
结果项字段:
title
,
url
,
description
,
publisher
,
year
,
citations
,
pdf?
,
id
,
html()

Google Patents

Google Patents

js
const page = await google('touchscreen gestures apple', { type: 'patents' })
Result:
title
,
description
,
url
,
priority
,
filing
,
grant?
,
publication
,
inventor
,
assignee
,
language
,
pdf?
,
thumbnail?
,
figures?
,
id?
,
html()
js
const page = await google('touchscreen gestures apple', { type: 'patents' })
结果项字段:
title
,
description
,
url
,
priority
,
filing
,
grant?
,
publication
,
inventor
,
assignee
,
language
,
pdf?
,
thumbnail?
,
figures?
,
id?
,
html()

Google Autocomplete

Google Autocomplete

js
const page = await google('how to', { type: 'autocomplete' })
Result:
value
(no
url
, no
html()
)
js
const page = await google('how to', { type: 'autocomplete' })
结果项字段:
value
(无
url
、无
html()
方法)

Pagination

分页功能

Every page exposes
.next()
returning a promise of the next page:
js
const page1 = await google('query')
const page2 = await page1.next()
Iterate through all pages:
js
let page = await google('node.js frameworks')

while (page) {
  for (const result of page.results) {
    console.log(result.title)
  }
  page = await page.next()
}
每个返回页对象都暴露了
.next()
方法,返回下一页结果的Promise:
js
const page1 = await google('query')
const page2 = await page1.next()
遍历所有页面示例:
js
let page = await google('node.js frameworks')

while (page) {
  for (const result of page.results) {
    console.log(result.title)
  }
  page = await page.next()
}

Lazy HTML Fetching

懒加载HTML获取

Any result with a
url
exposes
.html()
to fetch the target page HTML on demand:
js
const { results } = await google('node.js frameworks')
const html = await results[0].html()
Page-level
.html()
fetches the Google SERP HTML itself.
所有带有
url
的结果项都暴露了
.html()
方法,可按需拉取目标页面的HTML:
js
const { results } = await google('node.js frameworks')
const html = await results[0].html()
页面级的
.html()
方法则会拉取谷歌SERP页面本身的HTML。