N
N
newaitix2018-05-16 19:59:30
API
newaitix, 2018-05-16 19:59:30

How to get Google Doc text?

The task is to get the text of the document that lies in the Google Document.

I can't figure out the Google API. English needs to be learned, but that's tomorrow. Today we need to solve the problem.
Someone worked with Google API? Tell me an adequate tutorial or throw some experience on this issue.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2020-05-14
@oshliaer

Probably the easiest way to get the text of a Document is to use the Google Drive API.
Method

GET https://www.googleapis.com/drive/v3/files/fileId
returns a list of possible exports
{
  "exportLinks": {
    "application/rtf": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=rtf",
    "application/vnd.oasis.opendocument.text": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=odt",
    "text/html": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=html",
    "application/pdf": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=pdf",
    "application/epub+zip": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=epub",
    "application/zip": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=zip",
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=docx",
    "text/plain": "https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=txt"
  }
}

For your file with id "ABC" log in with permissions https://www.googleapis.com/auth/drive.readonlyand call
GET https://docs.google.com/feeds/download/documents/export/Export?id=ABC&exportFormat=txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question