G
G
Gasoid2010-09-07 09:19:18
Python
Gasoid, 2010-09-07 09:19:18

Exporting documents from google-docs via python-api

simple export code from google docs

# -*- coding: utf-8 -*-
import gdata.docs
import gdata.docs.service
gd_client = gdata.docs.service.DocsService()
gd_client.ClientLogin('[email protected]', 'superpassword')

#загружаем файл print.html в google docs
ms = gdata.MediaSource(file_path='print.html', content_type="text/html")
entry = gd_client.Upload(ms, 'NewDocument')

#экспортируем файл в doc
file_path = 'print.doc'
gd_client.Export(entry, file_path)



the output file format is pdf, not doc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gasoid, 2010-09-09
@Gasoid

pdb debugger helped to find the problem)
in general, in the gdata/docs/service.py file, in the _DownloadFile() function, added to the beginning:

    uri = uri.replace("export/","")

not the correct uri was formed for some reason.

V
Vladimir Chernyshev, 2010-09-07
@VolCh

Here blog.programmableweb.com/2009/02/20/google-api-now-lets-you-get-documents-in-many-formats/ seems to have what you need - there is a link to examples in several languages, I think you'll figure it out . Yes, protocol version 3.0, what's in Labs

G
Gasoid, 2010-09-09
@Gasoid

apparently it is necessary to fix api or wrapper to do,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question