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 string supports standard Google search operators:
queryjs
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)queryjs
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
参数选项
| Option | Type | Default | Values |
|---|---|---|---|
| | | |
| | | ISO 3166-1 alpha-2 country code |
| | — | |
| | — | Results per page |
| 参数 | 类型 | 默认值 | 可选值 |
|---|---|---|---|
| | | |
| | | ISO 3166-1 alpha-2标准国家代码 |
| | — | |
| | — | 每页返回结果数 |
Google Products
谷歌产品支持
Google Search (default)
Google Search(默认)
js
const page = await google('node.js frameworks')Page: , , ,
resultsknowledgeGraph?peopleAlsoAsk?relatedSearches?Result: , , ,
titleurldescriptionhtml()KnowledgeGraph: , , , , , , ,
title?type?website?image?description?descriptionSource?descriptionLink?attributes?js
const page = await google('node.js frameworks')页对象字段: , , ,
resultsknowledgeGraph?peopleAlsoAsk?relatedSearches?结果项字段: , , ,
titleurldescriptionhtml()知识图谱字段: , , , , , , ,
title?type?website?image?description?descriptionSource?descriptionLink?attributes?Google News
Google News
js
const page = await google('artificial intelligence', { type: 'news' })Result: , , , , , ,
titleurldescriptiondatepublisherimage?html()js
const page = await google('artificial intelligence', { type: 'news' })结果项字段: , , , , , ,
titleurldescriptiondatepublisherimage?html()Google Images
Google Images
js
const page = await google('northern lights', { type: 'images' })Result: , , , , , , ,
titleurlimage { url, width, height }thumbnail { url, width, height }google?creator?credit?html()js
const page = await google('northern lights', { type: 'images' })结果项字段: , , , , , , ,
titleurlimage { 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: , , , , , , , , , ,
titleurldescriptionimage?video?duration?duration_pretty?publisher?channel?date?html()js
const page = await google('cooking tutorial', { type: 'videos' })结果项字段: , , , , , , , , , ,
titleurldescriptionimage?video?duration?duration_pretty?publisher?channel?date?html()Google Places
Google Places
js
const page = await google('coffee shops denver', { type: 'places' })Result: , , , , , , ,
titleaddresslatitudelongitudephone?url?cidhtml()js
const page = await google('coffee shops denver', { type: 'places' })结果项字段: , , , , , , ,
titleaddresslatitudelongitudephone?url?cidhtml()Google Maps
Google Maps
js
const page = await google('apple store new york', { type: 'maps' })Result: , , , , , , , , , , , , , , , , ,
titleaddresslatitudelongituderating?ratingCount?price? { level }type?types?url?phone?description?opening?thumbnail?cidfid?place?html()js
const page = await google('apple store new york', { type: 'maps' })结果项字段: , , , , , , , , , , , , , , , , ,
titleaddresslatitudelongituderating?ratingCount?price? { level }type?types?url?phone?description?opening?thumbnail?cidfid?place?html()Google Shopping
Google Shopping
js
const page = await google('macbook pro', { type: 'shopping' })Result: , , , , , , ,
titleurlpublisherprice { symbol, amount }image?rating? { score, total, reviews? }id?html()js
const page = await google('macbook pro', { type: 'shopping' })结果项字段: , , , , , , ,
titleurlpublisherprice { symbol, amount }image?rating? { score, total, reviews? }id?html()Google Scholar
Google Scholar
js
const page = await google('transformer architecture', { type: 'scholar' })Result: , , , , , , , ,
titleurldescriptionpublisheryearcitationspdf?idhtml()js
const page = await google('transformer architecture', { type: 'scholar' })结果项字段: , , , , , , , ,
titleurldescriptionpublisheryearcitationspdf?idhtml()Google Patents
Google Patents
js
const page = await google('touchscreen gestures apple', { type: 'patents' })Result: , , , , , , , , , , , , , ,
titledescriptionurlpriorityfilinggrant?publicationinventorassigneelanguagepdf?thumbnail?figures?id?html()js
const page = await google('touchscreen gestures apple', { type: 'patents' })结果项字段: , , , , , , , , , , , , , ,
titledescriptionurlpriorityfilinggrant?publicationinventorassigneelanguagepdf?thumbnail?figures?id?html()Google Autocomplete
Google Autocomplete
js
const page = await google('how to', { type: 'autocomplete' })Result: (no , no )
valueurlhtml()js
const page = await google('how to', { type: 'autocomplete' })结果项字段: (无、无方法)
valueurlhtml()Pagination
分页功能
Every page exposes returning a promise of the next page:
.next()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()
}每个返回页对象都暴露了方法,返回下一页结果的Promise:
.next()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 exposes to fetch the target page HTML on demand:
url.html()js
const { results } = await google('node.js frameworks')
const html = await results[0].html()Page-level fetches the Google SERP HTML itself.
.html()所有带有的结果项都暴露了方法,可按需拉取目标页面的HTML:
url.html()js
const { results } = await google('node.js frameworks')
const html = await results[0].html()页面级的方法则会拉取谷歌SERP页面本身的HTML。
.html()