Google脚本可从Google趋势中导入数据 [英] Google Script to import data from Google trends

查看:98
本文介绍了Google脚本可从Google趋势中导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否存在一个脚本,可将数据从Google趋势中导入到Google表格中.基本上,我想每天触发此类脚本以了解给定主题的上升趋势,并且我不确定是否有这样的解决方案.

just wondering if there is a script to import data from google trends into a google sheet. Basically, I would like to trigger such script daily to know the rising trends for a given topic and I am not sure if there is such solution available.

否则,有什么解决方案可以执行此任务吗?

Else, is there any solution to perform this task?

非常感谢!

推荐答案

您可以参考以下示例代码有关如何使用Google Apps脚本查询Google趋势的摘要.例如,此函数从电子表格中读取输入并进行清理,然后调用queryGoogleTrends进行实际查询并最终显示实际结果:

You may refer with this sample code snippet on how to use Google Apps Script for querying Google trends. For example, this function read input from the spreadsheet and sanitize it, then call up queryGoogleTrends to perform actual query and finally display the actual result:

function startQuery() {
  sheet = SpreadsheetApp.getActiveSpreadsheet();

  // start the query
  var result = buildQueryString(sheet.getRangeByName("q").getValue(),
    sheet.getRangeByName("cat").getValue(),
    sheet.getRangeByName("geo").getValue(),
    sheet.getRangeByName("gprop").getValue(),
    sheet.getRangeByName("cmpt").getValue(),
    sheet.getRangeByName("date").getValue()
                    );

  // display the resulting link in a cell
  sheet.getRangeByName("Query_Result").setValue(result).setBackground("yellow");

  var csv_result = generateCsvDownload(sheet.getRangeByName("q").getValue(),
    sheet.getRangeByName("cat").getValue(),
    sheet.getRangeByName("geo").getValue(),
    sheet.getRangeByName("gprop").getValue(),
    sheet.getRangeByName("cmpt").getValue(),
    sheet.getRangeByName("date").getValue()
                    );

sheet.getRangeByName("CSV_Download_Link").setValue(csv_result).setBackground("yellow");

}

这篇关于Google脚本可从Google趋势中导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆