首页 > 解决方案 > 如何将数据抓取与谷歌表格连接起来

问题描述

我有这个来自网络抓取的代码

from smart_sensor_client.smart_sensor_client import SmartSensorClient
import json
import requests
import pprint
DEFAULT_SETTINGS_FILE = 'settings.yaml'


def run_task(settings_file=DEFAULT_SETTINGS_FILE) -> bool:

    # Create the client instance
    client = SmartSensorClient(settings_file=settings_file)

    # Authenticate
    if not client.authenticate():
        print('Authentication FAILED')
        return False

    # Get list of plants
    plants = client.get_plant_list()

    # Iterate the plant list and print all assets therein
    for plant in plants:
    
        # Get list of assets
        response = client.get_asset_list(organization_id=client.organization_id)
        if len(response) == 0:
            print('No assets in this plant')
        else:
            for asset in response:
                print(asset["assetName"],':',asset["lastSyncTimeStamp"])
               ...

以及下面的答案。我用我感兴趣的信息过滤的json。

Ventilador FCH 11 : 2020-06-11T09:48:45Z
VTL SVA1 : 2020-06-11T10:20:43Z
Dardelet PV-1 : 2020-06-11T09:58:14Z
CANDLOT 1 (MOTOR N°2) : 2020-06-11T10:37:39Z
PC N°1 S1/2A : 2020-06-11T10:57:34Z
VTL SVA2 : 2020-06-11T11:31:08Z
Ventilador FCH 6 : 2020-06-11T11:43:28Z
Vibrotamiz Tolva Tampon  : 2020-06-11T11:44:43Z
Ventilador FCH 10 : 2020-06-11T11:08:03Z

Task SUCCESS

我想把它粘贴到谷歌表上,但我不知道它是否可能。谢谢!

标签: pythonweb-scrapinggoogle-sheetspython-3.8

解决方案


推荐阅读