colab用

!pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

# Credit @tobias_willmann
from google.oauth2 import service_account
from googleapiclient.discovery import build
import pprint

def ppvars(obj):
    try:
        pprint.pprint(vars(obj))
    except:
        pprint.pprint(obj)

creds = "/content/sample_data/your-service-account-key.json"
 
scopes = [
    'https://www.googleapis.com/auth/webmasters',
    'https://www.googleapis.com/auth/webmasters.readonly'
    ]

credentials = service_account.Credentials.from_service_account_file(creds, scopes=scopes)
service = build('searchconsole','v1',credentials=credentials)

request = {
  'inspectionUrl': 'https://tech108.firenium.com/colab/',
  'siteUrl': 'sc-domain:psy.firenium.com'
}

response = service.urlInspection().index().inspect(body=request).execute()
inspectionResult = response
ppvars(inspectionResult)