简体   繁体   English

从网站获取数据并将其放在谷歌电子表格中

[英]GET data from website and put it at google spreadsheet

I know there is quite decent amount of topics about this, but I couldn't find any that seems to be working for me.我知道有很多关于此的主题,但我找不到任何似乎对我有用的主题。 I want to post some of the variables on google spreadsheet obtained by another website.我想在另一个网站获得的谷歌电子表格上发布一些变量。

I have some variables like:我有一些变量,例如:

var a = parseInt($('table.thinline:eq(4)>tbody>tr:eq(1)>td:eq(1)').text().replace(/\D/g,''),10);
var b = $('table.thinline:eq(0)>tbody>tr:eq(1)>td:eq(1)').text();
var c = parseInt($('table.thinline:eq(3)>tbody>tr:eq(2)>td:eq(1)').text().replace(/\D/g,''),10);

As soon as the page is being loaded, I want them to be posted on google spreadsheet in columns.加载页面后,我希望它们以列的形式发布在谷歌电子表格上。 So first column should pick values that are stored under variable a, second column - var b, third column - var c etc.所以第一列应该选择存储在变量 a 下的值,第二列 - var b,第三列 - var c 等。

I'd also like to avoid forms.我也想避免表格。

How to solve this?如何解决这个问题?

Thanks in advance.提前致谢。

If I understand your question correctly, you'd like to fill in your variables at the bottom of three individual rows of a Google Sheet.如果我正确理解您的问题,您希望在 Google Sheet 的三行底部填写您的变量。

This can be achieved with the .appendRow method.这可以通过 .appendRow 方法实现。 You'll find the docs here .您可以在此处找到文档。

 var spreadSheetID = ""; // Add string with the ID of your spreadsheet here var sheetName = ""; // Add string with the name of your Sheet here var a = "value for first column"; var b = "value for second column"; var c = "value for third column"; function appendRows() { var ss = SpreadsheetApp.openById(spreadSheetID); // Select Spreadsheet by ID var sheet = ss.getSheetByName(sheetName); // Select your Sheet by its Name sheet.appendRow([a, b, c]); } appendRows();

This appends a to row A, b to row B and c to row C.这将 a 附加到 A 行,b 附加到 B 行,c 附加到 C 行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM