python破解网站管理员_我们可以使用网站管理员来提取其他网站分析数据吗?

from__future__importprint_functionimportargparseimportsysfromgoogleapiclientimportsample_tools# Declare command-line flags.argparser=argparse.ArgumentParser(add_help=False)argparser.add_argument('property_uri',type=str,help=('Site or app URI to query data for (including ''trailing slash).'))argparser.add_argument('start_date',type=str,help=('Start date of the requested date range in ''YYYY-MM-DD format.'))argparser.add_argument('end_date',type=str,help=('End date of the requested date range in ''YYYY-MM-DD format.'))defmain(argv):service,flags=sample_tools.init(argv,'webmasters','v3',__doc__,__file__,parents=[argparser],scope='https://www.googleapis.com/auth/webmasters.readonly')# First run a query to learn which dates we have data for. You should always# check which days in a date range have data before running your main query.# This query shows data for the entire range, grouped and sorted by day,# descending; any days without data will be missing from the results.request={'startDate':flags.start_date,'endDate':flags.end_date,'dimensions':['date']}response=execute_request(service,flags.property_uri,request)print_table(response,'Available dates')defexecute_request(service,property_uri,request):"""Executes a searchAnalytics.query request.

Args:

service: The webmasters service to use when executing the query.

property_uri: The site or app URI to request data for.

request: The request to be executed.

Returns:

An array of response rows.

"""returnservice.searchanalytics().query(siteUrl=property_uri,body=request).execute()defprint_table(response,title):"""Prints out a response table.

Each row contains key(s), clicks, impressions, CTR, and average position.

Args:

response: The server response to be printed as a table.

title: The title of the table.

"""print('\n --'+title+':')if'rows'notinresponse:print('Empty response')returnrows=response['rows']row_format='{:<20}'+'{:>20}'*4print(row_format.format('Keys','Clicks','Impressions','CTR','Position'))forrowinrows:keys=''# Keys are returned only if one or more dimensions are requested.if'keys'inrow:keys=u','.join(row['keys']).encode('utf-8').decode()print(row_format.format(keys,row['clicks'],row['impressions'],row['ctr'],row['position']))if__name__=='__main__':main(sys.argv)``````json{"installed":{"client_id":"INSERT CLIENT ID HERE","client_secret":"INSERT CLIENT SECRET HERE","redirect_uris":[],"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token"}}```I was expecting the tablewithresults butImgetting url directedisnotmatched.I even tried'localhost:8080'inthe redirected url but itisnotworking

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值