[詢問] 請問google apps script的UrlFetchApp
想請問一下
我要在google apps script做一個函數
讓使用者可以在google sheet輸入關鍵字和一個網站的網址
計算出在用google搜尋該關鍵字時
該網站會排在第幾名
我的google apps script程式碼:
function getGoogleRank(keyword, url) {
var searchUrl = 'https://www.google.com/search?q=' + encodeURIComponent(keywor
d) + '&num=100';
var response = UrlFetchApp.fetch(searchUrl);
var content = response.getContentText();
var regex = new RegExp(url, 'i');
var rank = content.search(regex);
if (rank == -1) {
return '未排名';
} else {
return rank + 1;
}
}
出現以下的錯誤訊息:
Exception: Request failed for https://www.google.com returned code 429. Truncate
d server response: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN
">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><me...
(use muteHttpExceptions option to examine full response)
好像是太過頻繁跟google請求
該如何解決這個問題呢
謝謝
----
Sent from BePTT on my Samsung SM-G9980
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.236.30.87 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Google/M.1678337505.A.949.html
※ 編輯: ppppppppp (36.236.30.87 臺灣), 03/09/2023 12:52:27
Google 近期熱門文章
PTT數位生活區 即時熱門文章