简体   繁体   English

从 Google Sheets 电子表格调用 python 脚本的好方法是什么?

[英]What is a good way to call a python script from a Google Sheets spreadsheet?

I have a google spreadsheet that functions as a quote calculator.我有一个用作报价计算器的谷歌电子表格。 I am using python-requests and beautifulsoup to:我使用 python-requests 和 beautifulsoup 来:

  1. Grab values from the google sheet,从谷歌表中获取值,
  2. login to a supplier's website登录供应商的网站
  3. Access their online quote calculator访问他们的在线报价计算器
  4. Populate the supplier's online quote form.填写供应商的在线报价表。
  5. Submit the form提交表格
  6. Scrape their quote data from the resulting html code.从生成的 html 代码中抓取他们的报价数据。
  7. Populate the google sheet with their cost information用他们的成本信息填充谷歌表

I don't need help with the python code or getting the python code to modify the googlesheet.我不需要有关 python 代码的帮助或获取 python 代码来修改 googlesheet。

what I can't find seemingly anywhere is a good process for calling the python code from within the google sheet.我似乎在任何地方都找不到的是从谷歌表中调用 python 代码的一个很好的过程。

Ideally, I'd like to have an object in the google sheet (button? link?) that will trigger the web-scraping functionality.理想情况下,我希望在谷歌表(按钮?链接?)中有一个对象,它将触发网络抓取功能。 I have seen Google Sheets scripts that claim to populate a spreadsheet with scraped data from outside webpages, but these tools don't handle any site with authentication, hence the python angle.我见过声称使用从外部网页抓取的数据填充电子表格的 Google Sheets 脚本,但这些工具不处理任何具有身份验证的站点,因此是 python 角度。

Any suggestions much appreciated.任何建议非常感谢。

Everything I've found online explains how to get a process running on GAE to call a Google App script.我在网上找到的所有内容都解释了如何在 GAE 上运行进程以调用 Google App 脚本。 Nothing about going the other way around.没有什么可以反过来的。

Google Apps Script . Google Apps 脚本 You will need to use Apps Script to add a button or menu item to the sheet and then trigger your python script.您将需要使用 Apps 脚本向工作表添加按钮或菜单项,然后触发您的 Python 脚本。 You will have to make your python code accessible through some web api and call that api via Apps Script using the UrlFetch service.您必须通过某些 Web api 访问您的 python 代码,并使用 UrlFetch 服务通过 Apps 脚本调用该 api。

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

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