SerpApi
透過 SerpAPI 提供即時搜尋引擎結果。 在不管理代理、驗證碼或解析器的情況下,爬取 Google、Bing、YouTube、Google Scholar 等平台。 SerpApi 負責基礎設施,讓你的工作流程收到乾淨且結構化的 JSON。
此連接器適用於以下產品和區域:
| Service | Class | Regions |
|---|---|---|
| Copilot Studio | 進階 | 除以下部分外,所有Power Automate區域: - 美國政府 (GCC) - 美國政府(海灣合作委員會高中) - 由 21Vianet 營運的中國雲 - 美國國防部 (DoD) |
| 邏輯應用程式 | 標準 | 所有 Logic Apps 區域, 但下列區域除外: - Azure Government 區域 - Azure 中國區域 - 美國國防部 (DoD) |
| Power Apps | 進階 | 除以下部分外,所有Power Apps區域 - 美國政府 (GCC) - 美國政府(海灣合作委員會高中) - 由 21Vianet 營運的中國雲 - 美國國防部 (DoD) |
| Power Automate(自動化服務) | 進階 | 除以下部分外,所有Power Automate區域: - 美國政府 (GCC) - 美國政府(海灣合作委員會高中) - 由 21Vianet 營運的中國雲 - 美國國防部 (DoD) |
| 聯絡方式 | |
|---|---|
| 名稱 | SerpApi |
| URL | https://serpapi.com |
| support@serpapi.com |
| 連接器中繼資料 | |
|---|---|
| 發行者 | SerpApi |
| 網站 | https://serpapi.com |
| 隱私策略 | https://serpapi.com/legal/privacy |
| 類別 | 網站;商業智慧 |
SerpApi
SerpApi 是一個即時搜尋引擎結果 API。 它處理代理、驗證碼和解析,讓你的 Power Apps 和 Power Automate 流程能收到乾淨、結構化的 JSON 而不必管理任何爬蟲基礎設施。
Publisher:SerpApi
先決條件
- 一個 SerpApi 帳號。 請於 serpapi.com 報名。
- 一個有效的 SerpApi API 金鑰。 免費方案每月包含250次搜尋。 付費方案可用於較高流量。
支援的作業
Google 搜尋(GoogleSearch)
取得特定查詢的結構化 Google 搜尋結果。 回傳自然結果、廣告、知識圖譜條目、相關問題、在地結果、頭條新聞等。 回傳的具體欄位取決於查詢內容以及 Google 搜尋的結果。
取得地點 (GetLocations)
回傳一份可傳遞給 location 搜尋參數的支援地理位置清單。 在搜尋前,請用這個工具查詢城市或地區的精確位置字串。
取得帳戶資訊 (GetAccount)
回傳您的 SerpApi 帳號資訊,包括目前方案、每月搜尋配額、剩餘搜尋次數及每小時使用統計數據。
取得憑證
- 請在 serpapi.com 登入您的 SerpApi 帳號。
- 導航到 serpapi.com/manage-api-key。
- 複製你的 API 金鑰。
- 在 Power Apps 或 Power Automate 建立連線時,請將你的 API 金鑰貼到 API 金鑰欄位。
你的 API 金鑰由 Power Platform 安全儲存,並自動注入每個請求。 連線建立後,你不需要再提供。
使用者入門
基本使用方式
此 GoogleSearch 動作會接收一個必要的參數(搜尋查詢)及一個可選的額外參數記錄:
Set(varJsonResponse, SerpApi.GoogleSearch("coffee"))
要以 HTML 文字控制項顯示原始 JSON 回應以供除錯:
$"<pre>{JSON(varJsonResponse, JSONFormat.IndentFour)}</pre>"
傳遞可選參數
可選參數會以記錄的形式傳遞(第二個參數)。 只包含你想設定的參數——省略鍵檻不會傳送該參數的任何參數,讓 SerpApi 使用自己的預設值。
以下範例中,輸入類型與名稱為建議,非強制。
Set(varJsonResponse, SerpApi.GoogleSearch(
searchQueryInput.Text,
{
location: locationInput.Text,
gl: glInput.Text,
hl: hlInput.Text,
lat: latInput.Text,
lon: lonInput.Text,
radius: radiusInput.Text,
uule: uuleInput.Text,
google_domain: googleDomainInput.Text,
cr: crInput.Text,
lr: lrInput.Text,
tbs: tbsInput.Text,
nfpr: nfprCheckbox.Value,
filter: filterCheckbox.Value,
safe: safeDropdown.Selected.Value,
device: deviceDropdown.Selected.Value,
tbm: tbmDropdown.Selected.Value,
start: startInput.Text,
ludocid: ludocidInput.Text,
lsig: lsigInput.Text,
kgmid: kgmidInput.Text,
si: siInput.Text,
ibp: ibpInput.Text,
uds: udsInput.Text,
no_cache: noCacheCheckbox.Value
}
))
控制類型映射:
| 參數類型 | 推薦的 Power Apps 控制 | 價值參考 |
|---|---|---|
| 文字 (字串) | 文字輸入 | controlName.Text |
| 布林值 | 切換或勾選框 | controlName.Value |
| Enum(固定選擇權) | 下拉式選單 | controlName.Selected.Value |
| Number | 文字輸入 | controlName.Text |
存取回應資料
回應是一個 JSON 物件。 直接從變數存取頂層屬性:
varJsonResponse.search_information.total_results
要將畫廊與有機成果綁定:
varJsonResponse.organic_results
將畫廊與當地商業成果綁定:
varJsonResponse.local_results.places
請參閱 SerpApi Google 搜尋文件 以了解完整的回應欄位清單。
查找有效的位置字串
用來GetLocations尋找精確的位置名稱並傳遞。GoogleSearch 參數 q 依據城市或地區名稱篩選,並 limit 限制回傳的結果數量。
Set(varLocations, SerpApi.GetLocations("Austin", {limit: 5}))
要將結果綁定到圖庫:
varLocations
集合中的每個項目都有 name、 canonical_name、 country_codetarget_typereachgps 和 欄位。 在後續canonical_name呼叫中將該location值作為GoogleSearch參數傳遞:
Set(varResults, SerpApi.GoogleSearch(
"coffee shops",
{location: locationGallery.Selected.canonical_name}
))
支票帳戶使用
用來 GetAccount 取得您目前的方案細節及配額使用情況。 這有助於確認在達到每月限制前還剩多少次搜尋。
Set(varAccount, SerpApi.GetAccount())
從回應中查看個別欄位:
varAccount.plan_searches_left
varAccount.this_month_usage
varAccount.account_rate_limit_per_hour
完整回應欄位清單請參閱 SerpApi Account API 文件 。
已知問題和限制
- 變數回應結構:Google 搜尋回應中的欄位取決於查詢內容及 Google 的回應。 並非所有欄位都會出現在每個回應中。 請參閱 SerpApi Google 搜尋文件 ,完整說明可能的回應欄位。
-
費率限制:請求受 SerpApi 方案的月度配額及每小時費率限制限制。 超過任一都會產生
429錯誤回應。 -
快取結果:預設情況下,SerpApi 會從快取中提供針對每位使用者(最多 1 小時前)重複請求的結果。 用參數
no_cache強制產生新的結果。 請注意,快取搜尋不計入您的每月配額。
支援
如需協助使用此連接器或您的 SerpApi 帳號,請聯絡 SerpApi 客服團隊:
- Email:contact@serpapi.com
- 即時聊天:全天候 24 小時在 serpapi.com 提供,您可以直接與 SerpApi 支援團隊成員對話。
正在建立連線
連接器支援下列驗證類型:
| 預設值 | 建立連線的參數。 | 所有地區 | 不可共享 |
預設
適用:所有地區
建立連線的參數。
這不是可共用的連線。 如果 Power App 與其他使用者共用,系統會明確提示其他使用者建立新連線。
| 名稱 | 類型 | Description | Required |
|---|---|---|---|
| API 金鑰 | 安全字串 | 你的 SerpApi API 金鑰。 可於以下網址查詢 https://serpapi.com/manage-api-key | 沒錯 |
動作
| Google 搜尋 |
取得特定查詢的結構化 Google 搜尋結果。 回傳自然結果、廣告、知識圖譜、相關問題、熱門新聞、在地結果等內容。 |
| 取得地點 |
回傳一份支援的地理位置清單,可用於搜尋時使用位置參數。 這對於尋找城市或地區的精確位置字串非常有用。 |
| 獲取帳戶信息 |
回傳已認證 SerpApi 帳號的資訊,包括方案細節、剩餘搜尋紀錄及使用統計。 |
Google 搜尋
取得特定查詢的結構化 Google 搜尋結果。 回傳自然結果、廣告、知識圖譜、相關問題、熱門新聞、在地結果等內容。
參數
| 名稱 | 機碼 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
搜尋查詢
|
q | True | string |
搜尋關鍵字。 支援所有標準運算子(例如 site:、inurl:、intitle:)及進階參數如 as_dt 和 as_eq。 |
|
地點
|
location | string |
搜尋的起點。 以城市層級為單位指定以獲得最佳準確度(例如德州奧斯汀)。 不能與 uule、lat 或 lon 參數一起使用。 請參閱 https://serpapi.com/locations-api 支援地點。 |
|
|
編碼位置(UULE)
|
uule | string |
Google 編碼的位置字串。 作為定位參數的替代方案,以實現精確的地理位置定位。 不能與位置、緯度、經度或橈骨一起使用。 |
|
|
緯度
|
lat | number |
搜尋來源的GPS緯度。 使用lon參數時必須如此。 不能和地點或烏勒一起使用。 |
|
|
緯度
|
lon | number |
搜尋來源的 GPS 經度。 使用闊度參數時必須如此。 不能和地點或烏勒一起使用。 |
|
|
半徑(公尺)
|
radius | integer |
以公尺為單位的距離,以偏向搜尋結果。 該區域內的成績排名較高。 可以搭配位置或緯度/經度一起使用。 最大半徑:桌面端為199公尺;1000公尺,無論是平板還是手機。 不能和 uule 一起使用。 |
|
|
Google 網域
|
google_domain | string |
要用的 Google 網域(例如 google.com、google.co.uk、google.fr)。 預設為 google.com。 完整名單請參見 https://serpapi.com/google-domains 。 |
|
|
Country
|
gl | string |
搜尋時使用兩字母國家代碼(例如 US、GB、FR、DE)。 完整名單請參見 https://serpapi.com/google-countries 。 |
|
|
語言
|
hl | string |
兩字母介面語言代碼(例如 en、es、fr、de)。 完整名單請參見 https://serpapi.com/google-languages 。 |
|
|
鄉村限制
|
cr | string |
將結果限制於來自特定國家的文件。 請使用 country{CODE} 格式 |作為分隔符(例如 countryFR|countryDE)。 |
|
|
語言限制
|
lr | string |
將結果限制在特定語言。 使用 lang_{code} 格式 |作為分隔符(例如 lang_fr|lang_de)。 |
|
|
進階搜尋篩選器
|
tbs | string |
進階搜尋篩選器(待搜尋)。 可依日期範圍、內容類型等篩選(例如 qdr:d 代表過去一天,qdr:w 顯示過去一週)。 |
|
|
安全搜尋
|
safe | string |
成人內容過濾的程度。 設為啟用以啟用過濾,關閉則是關閉。 |
|
|
排除自動校正結果
|
nfpr | integer |
設為 1 以排除原始查詢拼寫錯誤時自動更正的結果。 預設設為 0 以包含他們。 |
|
|
重複內容過濾器
|
filter | integer |
控制類似結果及省略結果篩選器。 設定為 1 以啟用(預設值),或設為 0 以停用。 |
|
|
搜尋類型
|
tbm | string |
要執行的 Google 搜尋類型(要匹配)。 省略,請在一般網路搜尋中搜尋。 |
|
|
結果抵銷
|
start | integer |
分頁偏移。 跳過給定數量的結果。 0 回傳第一頁,10 回傳第二頁,依此類推。 |
|
|
裝置
|
device | string |
要模擬的裝置類型。 使用桌面(預設)、平板或行動裝置。 |
|
|
繞過快取
|
no_cache | boolean |
設為 true,強制產生全新結果,繞過 SerpApi 的 1 小時快取。 快取搜尋是免費的,且不計入你的每月配額。 不要與非同步一起使用。 |
|
|
非同步模式
|
async | boolean |
將 true 設定為 True,以便透過 Search Archive API 提交搜尋並稍後取得結果,而非同步等待結果。 不要與 no_cache 一起使用。 |
|
|
輸出格式
|
output | string |
輸出格式。 結構化 JSON 預設為 json,原始 HTML 則設為 html。 使用 HTML 來除錯或尚未完全支援的結果類型。 |
|
|
刑偵所在地
|
ludocid | string |
Google特定地點的CID(客戶識別碼)。 如place_id在地方結果中。 用來取得某地的知識圖譜。 |
|
|
知識圖譜識別碼
|
kgmid | string |
Google 知識圖譜實體的 KGMID。 除了開始外,可能會覆蓋其他搜尋參數。 |
|
|
本地簽名(LSIG)
|
lsig | string |
用來強制某個地方的知識圖譜地圖視圖。 可透過本地包裝 API 或 Google 本地 API 取得。 |
|
|
快取搜尋參數(si)
|
si | string |
知識圖譜分頁的快取加密搜尋參數。 除了開始外,可能會覆蓋其他搜尋參數。 |
|
|
佈局擴充(IBP)
|
ibp | string |
控制 Google 結果中的版面擴充(例如 gwp;0,7). |
|
|
濾波器弦(UDS)
|
uds | string |
Google 提供的篩選字串用於結果篩選。 |
|
|
零痕跡
|
zero_trace | boolean |
僅限企業帳號。 設為 true,可以跳過伺服器端儲存的搜尋參數和元資料。 |
傳回
| 名稱 | 路徑 | 類型 | Description |
|---|---|---|---|
|
search_metadata
|
search_metadata | object |
關於搜尋請求的元資料,包括狀態、時間及 SerpApi 識別碼。 |
|
search_parameters
|
search_parameters | object |
這次搜尋所用的參數,也反映在請求中。 |
|
search_information
|
search_information | object |
關於搜尋的高層次資訊,例如總結果數和所花時間。 |
|
organic_results
|
organic_results | array of object |
Google 會回傳標準的自然網路結果。 |
|
items
|
organic_results | object | |
|
廣告
|
ads | array of object |
付費廣告顯示於自然結果上方或下方。 |
|
items
|
ads | object | |
|
knowledge_graph
|
knowledge_graph | object |
如果查詢中有 Google 知識圖譜面板資料。 |
|
related_questions
|
related_questions | array of object |
人們也會問與查詢相關的問題。 |
|
items
|
related_questions | object | |
|
related_searches
|
related_searches | array of object |
相關搜尋建議顯示於結果頁底部。 |
|
items
|
related_searches | object | |
|
local_results
|
local_results | object |
當查詢具有本地意圖時,會出現在局部包的結果。 |
|
top_stories
|
top_stories | array of object |
與該查詢相關的熱門新聞。 |
|
items
|
top_stories | object | |
|
分頁
|
pagination | object |
連結至下一頁及前一頁的結果。 |
取得地點
回傳一份支援的地理位置清單,可用於搜尋時使用位置參數。 這對於尋找城市或地區的精確位置字串非常有用。
參數
| 名稱 | 機碼 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
搜尋詞
|
q | string |
用城市或地區名稱來篩選可用地點列表(例如奧斯汀)。 |
|
|
極限
|
limit | integer |
最多可回放的地點數量。 |
傳回
- response
- array of Location
獲取帳戶信息
定義
地點
支援用於位置搜尋參數的地理位置。
| 名稱 | 路徑 | 類型 | Description |
|---|---|---|---|
|
id
|
id | string |
此地點的唯一識別碼。 |
|
名字
|
name | string |
地點全名(例如:奧斯汀、德州、美國)。 |
|
canonical_name
|
canonical_name | string |
位置參數中使用的典範名稱。 |
|
country_code
|
country_code | string |
兩字母 ISO 國家代碼。 |
|
target_type
|
target_type | string |
地點類型(例如城市、DMA 地區、國家)。 |
|
觸達
|
reach | integer |
該地點的每月搜尋量估計覆蓋率。 |
|
GPS
|
gps | array of number |
GPS 座標為[緯度、經度]。 |
帳戶資訊
關於已認證的 SerpApi 帳號資訊。
| 名稱 | 路徑 | 類型 | Description |
|---|---|---|---|
|
account_id
|
account_id | string |
帳戶的唯一識別碼。 |
|
API 密鑰 (api_key)
|
api_key | string |
這個帳號的 API 金鑰。 |
|
account_email
|
account_email | string |
與帳號綁定的電子郵件地址。 |
|
plan_name
|
plan_name | string |
目前訂閱方案名稱。 |
|
plan_monthly_price
|
plan_monthly_price | number |
目前方案的每月價格以美元計算。 |
|
searches_per_month
|
searches_per_month | integer |
目前方案每月包含的搜尋總數。 |
|
plan_searches_left
|
plan_searches_left | integer |
目前計費期間內剩餘搜尋次數。 |
|
extra_credits
|
extra_credits | integer |
額外搜尋積分可於計劃外購買。 |
|
account_rate_limit_per_hour
|
account_rate_limit_per_hour | integer |
每小時允許的最大 API 請求數。 |
|
this_month_usage
|
this_month_usage | integer |
本計費期間迄今使用的搜尋數量。 |
|
this_hour_searches
|
this_hour_searches | integer |
本小時內的搜尋次數。 |
|
last_hour_searches
|
last_hour_searches | integer |
過去一小時內的搜尋次數。 |