質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Google Cloud Platform

Google Cloud Platformは、Google社がクラウド上で提供しているサービス郡の総称です。エンドユーザー向けサービスと同様のインフラストラクチャーで運営されており、Webサイト開発から複雑なアプリ開発まで対応可能です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

0回答

1102閲覧

Cloud Functionでデプロイした関数を実行するとエラー"Error: could not handle the request"になる

kakomya19

総合スコア2

Google Cloud Platform

Google Cloud Platformは、Google社がクラウド上で提供しているサービス郡の総称です。エンドユーザー向けサービスと同様のインフラストラクチャーで運営されており、Webサイト開発から複雑なアプリ開発まで対応可能です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2022/11/26 02:26

編集2022/11/26 02:57

前提

GCPのCloud Functionに初めてトライするにあたり、
下記のWebページ通りに設定を進めていたところ、
デプロイ(webページ上の<4. デプロイ完了後、Cloud Functionsの画面に以下のように表示されます。>のところ)まではできたのですが
関数を実行するとエラーになります。

参考にしたサイト:Cloud SchedulerとCloud Functionsを使って自動スクレイピングさせて、スプレッドシートに書き出してみた(Python)
https://marketingengineercareer.com/cloudscheduler_cloudfunctions_python

実現したいこと

上記Webページ上の目次「5.3 Cloud Functions→6. wikipediaのどっかのページのタイトルが返ってきます。」までを実行させたいです。

発生している問題・エラーメッセージ

ターミナルで実行した場合のエラーメッセージ

Error: could not handle the request

テスト中タブでテストを実行した場合のエラーメッセージ

Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging Details: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

該当のソースコード

import os from selenium import webdriver def handler(request): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--window-size=1280x1696') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--hide-scrollbars') chrome_options.add_argument('--enable-logging') chrome_options.add_argument('--log-level=0') chrome_options.add_argument('--v=99') chrome_options.add_argument('--single-process') chrome_options.add_argument('--ignore-certificate-errors') chrome_options.binary_location = os.getcwd() + "/headless-chromium" driver = webdriver.Chrome(os.getcwd() + "/chromedriver",chrome_options=chrome_options) driver.get('https://en.wikipedia.org/wiki/Special:Random') line = driver.find_element_by_class_name('firstHeading').text print(line) driver.quit() return line

GCPのターミナル上に下記を入力して実行しています。(*****のところは自分の関数のURLを入れています)

curl https://asia-northeast1-************.cloudfunctions.net/handler

試したこと

・該当する関数のAuthenticationを「未認証を許可」に変更→エラーまま
・Cloud Functionの下記テストコマンドを実行→同じエラー

curl -m 70 -X POST https://asia-northeast1-************.cloudfunctions.net/handler \ -H "Authorization: bearer $(gcloud auth print-identity-token)" \ -H "Content-Type: application/json" \ -d '{}'

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問