Python 如何从每个站点获取项目列表,然后从每个项目获取工作簿列表?

Python 如何从每个站点获取项目列表,然后从每个项目获取工作簿列表?,python,tableau-api,Python,Tableau Api,首先我想要一个站点列表,然后我想要每个站点中的项目列表,然后我想要每个项目中的工作簿列表 i、 e站点>>项目>>工作手册 我正在使用Tableauserverclient。请帮助我,提前谢谢。查看Tableau的页面。它有所有的例子 我会考虑使用TabLeo的数据库,除非您需要Python进行其他操作。< /P> 地点 计划 工作手册 当我试图使用site.id获取项目列表时,我得到了登录错误。为什么?我们可以使用site.id代替TSC.tableauauth中的site.name进行登录?

首先我想要一个站点列表,然后我想要每个站点中的项目列表,然后我想要每个项目中的工作簿列表

i、 e站点>>项目>>工作手册

我正在使用Tableauserverclient。请帮助我,提前谢谢。

查看Tableau的页面。它有所有的例子

我会考虑使用TabLeo的数据库,除非您需要Python进行其他操作。< /P> 地点

计划

工作手册


当我试图使用site.id获取项目列表时,我得到了登录错误。为什么?我们可以使用site.id代替TSC.tableauauth中的site.name进行登录?站点部分将在不定义站点id的情况下运行。我已编辑了答案以反映。我们可以在tableauauth方法中获取特定站点的项目列表pass site\u id=site.content\u url
import tableauserverclient as TSC  
tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD')  
server = TSC.Server('https://SERVER')  

# query the sites
all_sites, pagination_item = server.sites.get()

# print all the site names and ids
for site in all_sites:
   print(site.id, site.name, site.content_url, site.state)
import tableauserverclient as TSC  
tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL')  
server = TSC.Server('https://SERVER')  

with server.auth.sign_in(tableau_auth): 
    # get all projects on site
    all_project_items, pagination_item = server.projects.get()
    print([proj.name for proj in all_project_items])
import tableauserverclient as TSC
tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
server = TSC.Server('https://servername')

with server.auth.sign_in(tableau_auth):
    all_workbooks_items, pagination_item = server.workbooks.get()
    # print names of first 100 workbooks
    print([workbook.name for workbook in all_workbooks_items])