Замена изображения в Документе Google с помощью Python APIPython

Программы на Python
Anonymous
Замена изображения в Документе Google с помощью Python API

Сообщение Anonymous »


I have a google doc that I am using as a template for creating thousands of automated reports. One part of that is to replace some of the images from the template and replace them with the correct image. I am struggling to get the ID of the image to replace, which doesnt sound like it should be very complicated. According to these docs https://developers.google.com/docs/api/ ... agerequest,

Код: Выделить всё

The ID of the existing image that will be replaced. The ID can be retrieved from the response of a get request.
But I dont know what request to make. I have tried getting the document like this:

Код: Выделить всё

document = docs_service.documents().get(documentId=document_id).execute()
, but I cannot see anything in there that is obviously an image, except for perhaps the

Код: Выделить всё

positionedObjectIds
field.
Here is the code with the missing field:

Код: Выделить всё

requests = [
{
"replaceImage": {
"imageObjectId": ¿where do I get this?,
"uri": f"https://drive.google.com/file/d/{image_id}/view?usp=drive_link",
"imageReplaceMethod": "CENTER_CROP",
}
}
]
Thanks in advance!


Источник: https://stackoverflow.com/questions/781 ... python-api

Вернуться в «Python»