2012-04-07 9 views
5

Google 문서 API를 사용하여 새로운 문서를 만들고 Google 문서의 특정 폴더에있는 모든 현재 문서의 목록을 제공하려고합니다. 나는 파이썬 개발로 시작하고있다. 그래서 나는 여전히 약간 거칠다.Python을 사용한 Google 문서 도구

상황이 내가 할 노력하고 있어요 :

  1. 이름과 모음 (또는 폴더)를 만듭니다 [폴더 이름]이 이름은 아직
  2. 가 내부 문서를 만들고 존재하지 않는 경우에만 [폴더 이름] 단지에서
  3. 은 [폴더 이름] 내가 구글 문서 도구 AP를 사용하고 믿는 문서를

을 자신을 에 대한 링크와 함께 문서의 목록을 얻을 나는 3.0을 사용하고있다. gdata-2.0.16 도우미를위한 python. 지금까지

코드 :

 

    import gdata.docs.data 
    import gdata.docs.client 

    class SampleConfig(object): 
     APP_NAME = 'GDataDocumentsListAPISample-v1.0' 
     DEBUG = False 

    client = gdata.docs.client.DocsClient() 
    client.ClientLogin('[email_address]','[password]',source=SampleConfig.APP_NAME) 

    col = gdata.docs.data.Resource(type='folder', title='Folder Name') 
    col = client.CreateResource(col) 

    doc = gdata.docs.data.Resource(type='document', title='I did this') 
    doc = client.CreateResource(doc, collection=col) 

그래서 지금의 질문에 : 나는 절망적으로 붙어입니다 : [폴더 이름] 존재하는 경우 내가 확인하려면 어떻게

  1. ?
  2. [폴더 이름]만의 내용을 검색하는 방법은 무엇입니까?
  3. 이 폴더에 생성 한 모든 문서에 대한 절대 링크를 얻으려면 어떻게해야합니까?

여기서부터 완성까지 마일이 멀다는 것을 알고 있습니다.하지만 도움이나 조언을 주시면 큰 도움이 될 것입니다.

미리 감사드립니다.

답변

3

You can query for a folder or document. 폴더가 있으면 해당 내용을 나열 할 수 있습니다.

# Create a query matching exactly a title, and include collections 
q = gdata.docs.client.DocsQuery(
    title='EFD', 
    title_exact='true', 
    show_collections='true' 
) 

# Execute the query and get the first entry (if there are name clashes with 
# other folders or files, you will have to handle this). 
folder = client.GetResources(q=q).entry[0] 

# Get the resources in the folder 
contents = client.GetResources(uri=folder.content.src) 

# Print out the title and the absolute link 
for entry in contents.entry: 
    print entry.title.text, entry.GetSelfLink().href 

출력 답변에 대한 자세한 내용은

My posted doc https://docs.google.com/... 
subtestcoll2 https://docs.google.com/... 
guestimates_1 https://docs.google.com/... 
phase 2 delivery plan - draft https://docs.google.com/... 
Meeting agenda June 09 https://docs.google.com/... 
Phase 2 spec for Graeme 2 March 2009 https://docs.google.com/... 
EFD Meeting 2nd June https://docs.google.com/... 
+0

감사합니다 다음은 파이썬 라이브러리 예입니다. 정말 고마워하고 내 생각에 기반하여 일하기 시작했다. 그러나 entry.GetSelfLink(). href는 다음 형식의 링크를 제공합니다. https : //docs.google.com/feeds/default/private/full/folder % .... 브라우저에서 사용하면 get 나 "잘못된 요청 URI" – user791793

관련 문제