最终通过管理使此Search Console API脚本在数据框(源)上起作用:
keyword date
keyword 1 2019-02-20
keyword 2 2019-03-18
keyword 3 2019-03-18
keyword 4 2019-04-16
keyword 5 2019-04-16
但是我所得到的只是这个:
keyword date test
keyword 1 2019-02-20 ((174.0, 3753.0, 0.04636290967226219, 7.816147...
keyword 2 2019-03-18 ((93.0, 2155.0, 0.0431554524361949, 6.59025522...
keyword 3 2019-03-18 ((176.0, 4657.0, 0.037792570324243074, 6.90251...
keyword 4 2019-04-16 ((20.0, 1102.0, 0.018148820326678767, 7.435571...
keyword 5 2019-04-16 ((31.0, 1133.0, 0.02736098852603707, 8.0935569...
这是我正在使用的代码: (基于此git-https://github.com/joshcarty/google-searchconsole)
account = searchconsole.authenticate(client_config='client_secrets.json', credentials='credentials.json')
webproperty = account['https://www.sample.com/']
def APIsc(date,keyword):
result=webproperty.query.range(date, days=-30).filter('query', keyword, 'contains').get()
return result
source['test']=source.apply(lambda x: APIsc(x.date, x.keyword), axis=1)
source
我想要一个多索引:
上面的get方法创建一个像这样的表:
clicks impressions ctr position
31.0 1133.0 0.027361 8.093557
我希望它能根据源代码中的现有数据获取
keyword date
keword 5 2019-04-16
clicks impressions ctr position
31.0 1133.0 0.027361 8.093557
谢谢。