如何解决使用Google Apps脚本UrlFetchApp刮刮Google趋势
我正在尝试从以下页面中获取前20个趋势:https://trends.google.com/trends/trendingsearches/daily?geo=US使用UrlFetchApp
和Cheerio
,但我的divs
不断获得以下内容:
You are using unsupported browser. Some features may not work correctly. Upgrade to a modern browser,such as Google Chrome.Trends has upgraded to a newer version,which is not supported by this device.dismiss,You are using unsupported browser. Some features may not work correctly. Upgrade to a modern browser,Google apps,Google apps
我尝试将header
选项设置为一堆不同的组合,但所有组合均无用。我也尝试使用Postman,结果也一样。
这是我的基本代码:
function getSearchTrends(url) {
var response = UrlFetchApp.fetch(url);
var status_code = response.getResponseCode();
if (status_code == 200) {
var content = response.getContentText();
const $ = Cheerio.load(content)
const divs = [];
$('div').each(function(i,elem) {
divs[i] = $(this).text();
});
Logger.log(divs);
}
}
是否存在某种变通方法来获得有用的HTML响应?谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。