LoginSignup
3
4

More than 1 year has passed since last update.

Google Apps Script(GAS)で翻訳API作成【Google Translate】

Last updated at Posted at 2022-04-24
function doGet(e) {
  const text = LanguageApp.translate(e.parameter.text, e.parameter.src, e.parameter.dest || 'ja')
  return ContentService.createTextOutput(text)
}

新しいプロジェクトを作成し、URLを作成することでAdvancedなAPIを作成できます。
https://script.google.com/macros/s/AKfycbxEpEZ3PNmT8fRE4ZnksmNV1Q5Hgs3QCJ7lWC4LUcWKKhScotN9OPxVDbMKdCLWU8NT/exec?text=This is a cat.

curl
curl -L https://script.google.com/macros/s/AKfycbxEpEZ3PNmT8fRE4ZnksmNV1Q5Hgs3QCJ7lWC4LUcWKKhScotN9OPxVDbMKdCLWU8NT/exec?text=apple
Python
import requests

print(requests.get('https://script.google.com/macros/s/AKfycbxEpEZ3PNmT8fRE4ZnksmNV1Q5Hgs3QCJ7lWC4LUcWKKhScotN9OPxVDbMKdCLWU8NT/exec', {'text': 'This is a cat.'}).text)

URLを作成する

新しいデプロイをクリック

image.png

ウェブアプリをクリック

image.png

全員を選択し、デプロイ

image.png

URLをコピー

image.png

デモ

See the Pen Google 翻訳 by John Doe (@04) on CodePen.

参考

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4