用關鍵字查詢 Google 搜尋結果或 Google 新聞報導,回傳結構化 JSON(含標題、連結、摘要等)。認證以 Authorization: Bearer YOUR_API_KEY 標頭帶開發者金鑰(也接受 X-Dev-Key 標頭),或已登入的網頁 session;金鑰不可放在網址查詢參數(會進入伺服器紀錄)。兩者皆為 GET,參數 q(關鍵字,string)必填;呼叫成功會自動扣點數,查詢失敗或查無結果不扣點。
GET /ntue/api/google/searchGoogle 搜尋,回傳網頁結果(每筆含 title/link/snippet)。選填參數:hl 介面語言、gl 地區、lr 結果語言、cr 來源國家、tbm 類型(nws 新聞/isch 圖片…)、tbs 時間等篩選(qdr:d 一天內/qdr:w 一週…)。
curl "https://www.myai168.com/ntue/api/google/search?q=Trump&hl=zh-TW&gl=tw" \
-H "Authorization: Bearer YOUR_DEV_KEY"
import requests
r = requests.get(
"https://www.myai168.com/ntue/api/google/search",
headers={"Authorization": "Bearer YOUR_DEV_KEY"},
params={"q": "Trump", "hl": "zh-TW", "gl": "tw"},
)
print(r.json())
GET /ntue/api/google/newsGoogle 新聞,回傳新聞報導(每筆含 title/link/source/date;連結會盡量還原為原始文章網址)。選填參數:hl 介面語言、gl 地區、ceid(格式 國家:語言,例 TW:zh-Hant)、num 回傳筆數(1~20,預設 10)。
curl "https://www.myai168.com/ntue/api/google/news?q=Taiwan&hl=zh-TW&gl=tw&num=10" \
-H "Authorization: Bearer YOUR_DEV_KEY"
import requests
r = requests.get(
"https://www.myai168.com/ntue/api/google/news",
headers={"Authorization": "Bearer YOUR_DEV_KEY"},
params={"q": "Taiwan", "hl": "zh-TW", "gl": "tw", "num": "10"},
)
print(r.json())
成功回 HTTP 200 JSON 物件:帶回生效的查詢參數(q/hl/gl 等)、count(筆數)、results(結果陣列)、cost(本次扣點)與 credits(扣後餘額)。搜尋的 results 每筆含 title/link/snippet;新聞每筆含 title/link/source/date(連結會盡量還原為原始文章網址)。
{
"q": "Taiwan",
"count": 10,
"results": [
{"title": "...", "link": "https://...", "source": "...", "date": "..."}
],
"cost": 66,
"credits": 12345
}
| HTTP 狀態 | 意義 |
|---|---|
401 | 金鑰缺漏或無效(同 IP 連續失敗會被暫時封鎖)。 |
402 | 點數不足(請先儲值)。 |
400 | 缺 q 參數或參數格式錯誤。 |
502 | 搜尋服務暫時失敗——一律不扣點。 |