0

我正在python中尝试以下代码

import searchconsole
import pandas as pd
import os

creds = 'client_secrets.json'

def authenticate(config='client_secrets.json', token='credentials.json'):
    """Authenticate GSC"""
    if os.path.isfile(token):
        account = searchconsole.authenticate(client_config=config,
                                            credentials=token)
    else:
        account = searchconsole.authenticate(client_config=config,
                                        serialize=token)
    return account

account = authenticate(config=creds)

site = 'example.com'
months = -5

webproperty = account[site]
report = webproperty.query\
        .range('today', months=months)\
        .dimension('page', 'query')\
        .get()
        
df = report.to_dataframe()
print(df.head())

我已经验证了该属性,并且在测试代码时,我得到了AttributeError: 'NoneType' object has no attribute 'query'

4

0 回答 0