简体   繁体   中英

Update google sheet from python script

I'm trying to have a python script update a google sheets. The script scrapes a dynamically loaded webpage and retrieves some values.

Because the site loads dynamically, I can't use google scripts. But if I wan't the python script to access the google sheet, I need a google service account. This requires a credit card, but I don't have access to a non-prepaid one.

I could also host the python API on gae, but this also requires a credit card.

Any ideas for how I could work around this?

I believe your goal as follows.

  • You want to put the values to Google Spreadsheet using python.

In order to achieve your goal, how about the following patterns?

1. Access to Google Spreadsheet using Sheets API with OAuth2.

When Sheets API is used, the values can be put to the Google Spreadsheet.

In this case, you can see the sample script at Quickstart . And, I think that in your situation, the use of Google Sheets API is free of charge. If you want to increase the quota of Sheets API, please check it at https://developers.google.com/sheets/api/limits .

2. Access to Google Spreadsheet using Sheets API with Service account.

When Sheets API is used, the values can be put to the Google Spreadsheet.

In this case, you can see the sample script from these threads . And also, I think that in your situation, the use of Google Sheets API is free of charge.

3. Access to Google Spreadsheet using Web Apps created by Google Apps Script.

When Google Apps Script is used, the values can be put to the Google Spreadsheet. And, in this method, Google Apps Script is used as the wrapper.

At first, create Web Apps using Google Apps Script, and your python script accesses to the Web Apps by sending the values with requests module. By this, at the Web Apps side, the retrieved values are put to Google Spreadsheet using Google Apps Script. The Web Apps is used as the wrapper API for using Google Spreadsheet. And also, in this case, you can also access to the Web Apps with and without using the access token. In this method, I think that your python script is simple modification.

In this case, you can see the detail information about Web Apps at Web Apps and Taking advantage of Web Apps with Google Apps Script .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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