code.gs below
function extractTextFromImages() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
for (let i = 1; i < data.length; i++) {
const imageUrl = data[i][0]; // Image URL in the first column
const text = getTextFromImage(imageUrl); // Extract text using OCR
sheet.getRange(i + 1, 2).setValue(text); // Write text to the second column
}
}
function getTextFromImage(imageUrl) {
const apiKey = ‘K84588088688957’;
const apiUrl = https://api.ocr.space/parse/imageurl?apikey=${apiKey}&url=${encodeURIComponent(imageUrl)}&language='tha'
; // Corrected: added backticks
const options = {
method: ‘get’,
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch(apiUrl, options);
const json = JSON.parse(response.getContentText());
// Extract the parsed text, or show “No text found” if none
const extractedText = json.ParsedResults && json.ParsedResults[0]
? json.ParsedResults[0].ParsedText
: “No text found”;
return extractedText;
}
i use google sheet
column 1 = image URL
column 2 = extracted text
the result
“text not found”
i follow by this channel