要通过URL查询Google Adsense数据,您需要使用Google Adsense API
YOUR_CLIENT_ID.json
替换为您下载的JSON文件路径。import os
import google.auth
from google.oauth2 import credentials
from googleapiclient.discovery import build
# 设置环境变量以存储凭据
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'YOUR_CLIENT_ID.json'
# 获取凭据
creds, project_id = google.auth.default()
# 构建Adsense API客户端
adsense_service = build('adsense', 'v1.4', credentials=creds)
# 查询账户信息
accounts = adsense_service.accounts().list().execute()
print(accounts)
领取专属 10元无门槛券
手把手带您无忧上云