【问题标题】:Download a Google Sites page Content Feed using gdata-python-client使用 gdata-python-client 下载 Google 协作平台页面内容提要
【发布时间】:2012-09-28 06:32:00
【问题描述】:

我的最终目标是从 Google 网站页面导入一些数据。 我正在尝试使用 gdata-python-client (v2.0.17) 下载特定的内容提要:

self.client = gdata.sites.client.SitesClient(source=SOURCE_APP_NAME)
self.client.client_login(USERNAME, PASSWORD, source=SOURCE_APP_NAME, service=self.client.auth_service)     
self.client.site = SITE
self.client.domain = DOMAIN

uri = '%s?path=%s' % (self.client.MakeContentFeedUri(), '[PAGE PATH]')
feed = self.client.GetContentFeed(uri=uri)
entry = feed.entry[0]
...

生成的 entry.content 具有 xhtml 格式的页面内容。但是此树不包含页面中的任何计划文本数据。只有 html 页面结构和链接。

例如我的测试页有

 <div>Some text</div>

ContentFeed 条目只有 div 节点和 text=None

我已经调试了 gdata-python-client 请求/响应并检查了原始缓冲区中来自服务器的解析数据 - 内容中的任何计划文本数据。因此,这是一个 Google API 错误。

可能有一些解决方法?可能我可以使用一些常见的请求参数吗?这里出了什么问题?

【问题讨论】:

    标签: python google-data-api google-sites gdata-python-client


    【解决方案1】:

    此代码适用于 Google Apps 域和 gdata 2.0.17:

    import atom.data
    import gdata.sites.client
    import gdata.sites.data
    
    client = gdata.sites.client.SitesClient(source='yourCo-yourAppName-v1', site='examplesite', domain='example.com')
    client.ClientLogin('admin@example.com', 'examplepassword', client.source);
    
    uri = '%s?path=%s' % (client.MakeContentFeedUri(), '/home')
    feed = client.GetContentFeed(uri=uri)
    entry = feed.entry[0]
    print entry 
    

    鉴于,它与您的几乎相同,但它可能会帮助您证明或反驳某些事情。祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 2011-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      相关资源
      最近更新 更多