小编Tan*_*ike的帖子

如何使用 google docs 将 PDF 内容提取到 .txt 文件中?

如何以编程方式使用 google 文档以编程方式从 pdf 文件中提取文本?我都知道还有其他选择,但是,我很好奇是否可以将谷歌文档用于此类目的。

python google-docs python-3.x google-drive-api

3
推荐指数
1
解决办法
1799
查看次数

使用 Google Scripts 的 Binance API 签名

我被困在如何根据Google Scripts中的Binance API正确地将签名包含到我的 get 命令中。它所说的是

SIGNED 端点需要在查询字符串或请求正文中发送附加参数签名。端点使用 HMAC SHA256 签名。HMAC SHA256 签名是加密的 HMAC SHA256 操作。使用您的 secretKey 作为密钥,使用 totalParams 作为 HMAC 操作的值。签名不区分大小写。totalParams 定义为与请求正文连接的查询字符串。

我所拥有的是:

function BinanceTrades() {
  var curTime = Number(new Date().getTime()).toFixed(0)
  var sKey = Utilities.computeHmacSha256Signature('symbol=LTCBTC&timestamp=' + curTime, '**mySeceretKey**');
  Logger.log(sKey)
  var headers = {'X-MBX-APIKEY': '**myKey**'}
  var data = UrlFetchApp.fetch("https://api.binance.com/api/v3/allOrders?signature=" + sKey + "&symbol=LTCBTC&timestamp=" + curTime, {'headers' : headers})
  Logger.log(data)
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

{"code":-1100,"msg":"在参数'signature'中发现非法字符;合法范围是'^[A-Fa-f0-9]{64}$'。"}

我不确定如何正确计算 HMAC SHA256 并合并 totalParams。

我以前的帖子是这样的。

javascript google-sheets urlfetch google-apps-script

3
推荐指数
1
解决办法
2334
查看次数

Google Drive API v3:service.files().list 未返回所有文件夹

我正在根据 Google Team Drive 文件的内容实现一个基于树的查看器;为此,我遵循此处给出的建议:How do I search sub-folders and sub-sub-folders in Google Drive? ,即执行 2 个 API 调用 - 一个用于获取所有文件夹,另一个用于获取这些文件夹的直接子级的所有文件。

但是,我注意到获取所有文件夹的调用并未返回所有文件夹:


res = service.files().list(
corpora='teamDrive',
pageSize=1000,
supportsTeamDrives=True,
includeTeamDriveItems=True,
teamDriveId=TEAM_DRIVE_ID,
fields='files(id,parents,name,mimeType)',
q="mimeType='application/vnd.google-apps.folder' and trashed=false"
).execute()

len(res['files'])
# 460

Run Code Online (Sandbox Code Playgroud)

在这里,文件不应该超过pageSize,但我肯定从这个结果中丢失了大量文件夹,例如 id 为 的特定文件夹specified_id


len([x for x in res['files'] if x['id'] == specified_id])
# 0

Run Code Online (Sandbox Code Playgroud)

我不认为这是权限问题,因为我可以正常获取此文件:


specific_file = service.files().get(
    fileId=specified_id,
    supportsTeamDrives=True,
).execute()

specific_file

{'id': '...',
 'kind': 'drive#file',
 'mimeType': 'application/vnd.google-apps.folder',
 'name': '...',
 'teamDriveId': '...'}

Run Code Online (Sandbox Code Playgroud)

为了实现在一个 API 请求中获取 Google(团队)云端硬盘中的所有文件夹的目标,有关尝试其他事情的任何其他提示将不胜感激。

python google-drive-api google-drive-shared-drive

3
推荐指数
1
解决办法
4611
查看次数

在js中获取google api中多个工作表的所有数据

我正在尝试使用 javascript 从 google 工作表获取一些数据。我的工作表中有多个工作表。我成功获取单个工作表的所有数据。但我需要从所有工作表中获取所有数据。这是我的单个工作表的代码。

$.ajax({
    type: 'get',
    url: 'https://sheets.googleapis.com/v4/spreadsheets/{sheet_id}/values/sheet1?key={API_KEY}',
    async: false,
    success: function(response) {

    }
});
Run Code Online (Sandbox Code Playgroud)

谁能帮我获取所有工作表的所有数据?

javascript google-sheets google-sheets-api

3
推荐指数
1
解决办法
3961
查看次数

将 XLSX 文件从每月电子邮件(在 Gmail 中)导入到指定的 Google Sheet

我定期收到客户发来的 XLSX 文件,我希望自动执行将其从 Gmail(自动标记)导入 Google 表格的过程。到目前为止,我设法使其适用于 CSV 文件,但 XLSX 文件似乎更棘手。有人可以帮助调整我的 CSV 文件代码吗?

\n\n
function getCSV() \n{\n  var thread = GmailApp.getUserLabelByName(\xe2\x80\x98Reconciliation\xe2\x80\x99).getThreads(0,1);\n  var messages = thread[0].getMessages();\n  var len = messages.length;\n  var message=messages[len-1] //get last message\n  var attachments = message.getAttachments(); // Get attachment of first message\n\n  var csv =  attachments[0].getDataAsString();\n  var data = Utilities.parseCsv(csv);\n\n  var sheet = SpreadsheetApp.openById("some id").getSheetByName(\xe2\x80\x98Data\xe2\x80\x99);\n  sheet.clearContents();\n  var range = sheet.getRange(1, 1, data.length, data[0].length);\n  range.setValues(data);\n}\n
Run Code Online (Sandbox Code Playgroud)\n

import google-sheets google-apps-script google-drive-api

3
推荐指数
1
解决办法
3218
查看次数

使用 python 的 Google API 文件权限

我需要为我网站的不同用户做一些功能来自动将 html 文件上传到谷歌磁盘并打开它们以在谷歌文档中查看和编辑。为此,我创建了一个文档,将其传递到 google 磁盘并使用创建的文档的 id 在 google docs 中打开它。
为了访问 api,我使用了从服务 Google 帐户中获取的 json 文件。我试图以所有者查看权限执行我的代码,但结果是一样的。

class CvView(AuthorizedMixin, View):
    """Here I check if the file format is html, I temporarily save it on disk and pass it to the file_to_drive function (to save it to google disk and open it in google docs) and delete it from disk"""


    def get(self, request, employee_id, format_):
        """Returns employee's CV in format which is equal to `format_`
        parameter."""

        employee = …
Run Code Online (Sandbox Code Playgroud)

python django google-api google-drive-api google-api-python-client

3
推荐指数
1
解决办法
1965
查看次数

使用 google drive.files.copy 时设置新文件名

我正在使用谷歌驱动器 apiv3 将电子表格复制到谷歌驱动器上的文件夹中。该文档指出“名称”属性应该用于设置新工作表的标题。我正在使用它,但新创建的工作表被命名为“{titleOfSheetToCopy} 的副本”。

要求:

app.get('/new', function (req, res) 
{
    var drive = google.drive({version:'v3', auth: jwt_client});

    var copyRequest = {
        name: 'im a copy',
        fileId: 'idOfSheetToClone',
        parents: ['idOfDestinationFolder'],
    }

    drive.files.copy(copyRequest,  function(err, response){
        if(err){
            console.log(err);
            res.send('error');
            return;
        }
        res.send(response);
    });
});
Run Code Online (Sandbox Code Playgroud)

回复:

{
"config": {
    "url": "https://www.googleapis.com/drive/v3/files/-----/copy?name=im%20a%20copy&parents=---",
    "method": "POST",
    "headers": {
        "Accept-Encoding": "gzip",
        "User-Agent": "google-api-nodejs-client/0.7.2 (gzip)",
        "Authorization": "---",
        "Accept": "application/json"
    },
    "params": {
        "name": "im a copy",
        "parents": [
            "---"
        ]
    },
    "responseType": "json"
},
"data": {
    "kind": "drive#file",
    "id": "---", …
Run Code Online (Sandbox Code Playgroud)

node.js google-drive-api

3
推荐指数
1
解决办法
686
查看次数

使用 google Drive api 上传 Excel 文件

我在使用 Google Drive API 时遇到问题。

我正在尝试使用此 API 上传 Excel 文件,但它不起作用。即使复制 google API 文档也不起作用。

这是我的代码示例:

@Get('teste')
async teste(){
    const keys = require(path.resolve('src', 'files', 'api', 'keys'))
    const client = new google.auth.JWT(
        keys.client_email,
        null,
        keys.private_key,
        ['https://www.googleapis.com/auth/drive.metadata.readonly']
    )

    client.authorize((err, tokens) =>{
        if(err){
            console.log(err)
            return;
        } else{
            this.gdrun(client)
        }
    })

}

gdrun(client){
    const drive = google.drive({version: 'v3', auth: client});

    var fileMetadata = {
        name: 'My Report',
        mimeType: 'application/vnd.google-apps.spreadsheet'
    };
    var media = {
        mimeType: 'application/vnd.ms-excel',
        body: require(path.resolve('src', 'files', 'excel', 'solargroup.xlsx'))
    };
    drive.files.create({
        resource: fileMetadata,
        media: …
Run Code Online (Sandbox Code Playgroud)

javascript excel google-api node.js google-drive-api

3
推荐指数
1
解决办法
2215
查看次数

是否可以查看 Google 幻灯片中使用的所有对象的列表?

当 Google 幻灯片中的某些对象隐藏在另一个对象后面时,以后可能很难在幻灯片上找到它们。例如,是否可以看到一个面板,其中包含给定幻灯片上存在的所有对象的列表?即使它们位于底层(完全隐藏在另一个对象后面),也可能编辑它们吗?当稍后显示对象并完全覆盖先前显示的对象时,这对于动画可能很有用。

在此输入图像描述

google-apps-script google-slides

3
推荐指数
1
解决办法
3073
查看次数

CSV 到 Google Sheets python

我有一个 CSV 文件,我想将其放入 Google Sheet 中的 Sheet3 中。我希望有人可以帮助我完成这段代码。我正在使用谷歌API。到目前为止,我已经将 csv 上传到谷歌驱动器。现在我想更改代码以更新sheet3中的特定google工作表而不是创建新工作表。您将在下面找到我用来创建包含 CSV 数据的新工作表的代码。

# Import Csv to Google Drive
import os
import glob

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()           
drive = GoogleDrive(gauth)  

 
# line used to change the directory
os.chdir(r'DIRECTORY OF CSV')

list_of_files = glob.glob('DIRECTORY OF CSV\*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)

upload_file_list = [latest_file]
for upload_file in upload_file_list:
    gfile = drive.CreateFile({'parents': [{'id': 'THE GOOGLE ID'}]}) …
Run Code Online (Sandbox Code Playgroud)

python google-sheets google-sheets-api

2
推荐指数
1
解决办法
4366
查看次数