简体   繁体   English

这可能吗-填充Google电子表格的Python脚本?

[英]Is this possible - Python script to fill a Google spreadsheet?

I dont even know if this is possible. 我什至不知道这是否可能。 But if it is, can someone give me the broadstrokes on how I can use a Python script to populate a Google spreadsheet? 但是如果是这样,有人可以给我广泛的笔触,说明如何使用Python脚本填充Google电子表格吗?

I want to scrape data from a web site and dump it into a google spreadsheet. 我想从网站上抓取数据并将其转储到Google电子表格中。 I can imagine what the Python looks like (scrapy, etc). 我可以想象Python是什么样的(草率的等等)。 But does the language support writing to Google Drive? 但是该语言是否支持写入Google云端硬盘? Can I kick off the script within the spreadsheet itself or would it have to run outside of it? 我可以在电子表格本身中启动脚本,还是必须在电子表格之外运行脚本?

Ideal scenario would be to open a google spreadsheet, click on a button, Python script executes and data is filled in said spreadsheet. 理想的情况是打开一个Google电子表格,单击一个按钮,执行Python脚本并将数据填充到所述电子表格中。

Google GData (library with interfaces for all Google services) Python client: Google GData(具有用于所有Google服务的界面的库)Python客户端:

https://code.google.com/p/gdata-python-client/ https://code.google.com/p/gdata-python-client/

Spreadsheets API docs (linked from previous page): 电子表格API文档(从上一页链接):

https://developers.google.com/google-apps/spreadsheets/?csw=1 https://developers.google.com/google-apps/spreadsheets/?csw=1

The question is from 2013. But still, as I was interested today by the answer, I though it could help some other people : 问题是从2013年开始的。但是,尽管我今天对答案很感兴趣,但我可以帮助其他人:

Google developed GScript, equivalent of VBA from Microsoft. Google开发了GScript,相当于Microsoft的VBA。 I guess with this language you can easily scrape web data and include them into the sheet. 我想用这种语言,您可以轻松地抓取Web数据并将其包含在表单中。

Otherwise, if you want to use Python, here is a great tutorial explaning how to use Google API v4: 否则,如果您想使用Python,这是一个很棒的教程,介绍了如何使用Google API v4:

https://developers.google.com/sheets/api/quickstart/python https://developers.google.com/sheets/api/quickstart/python

The missing step: launching python script directly from the google sheet. 缺少的步骤:直接从Google工作表启动python脚本。

I hope it helps ! 希望对您有所帮助!

Yes, it is possible and this is how I am personally doing it so. 是的,这是可能的,这就是我个人这样做的方式。

search for "doGet" and "doPost(e) 搜索“ doGet”和“ doPost(e)

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

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