0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

chrome, chromedriver のコマンドラインでのダウンロード(バージョン115以降)

Posted at

概要

ブラウザ chrome とウェブドライバ chromedriver をコマンドラインでのダウンロード方法を記録します。
この2つはバージョン115以降、JSONエンドポイントにアクセスすることでセットでダウンロードURLを取得できる。

JSONエンドポイント

JSON API endpoints はリポジトリにまとまっている。

ダウンロードURL付きで利用しやすいのは last-known-good-versions-with-downloads.json と考えている。

$ curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
{
  "timestamp": "2023-09-07T03:08:43.543Z",
  "channels": {
    "Stable": {
      "channel": "Stable",
      "version": "116.0.5845.96",
      "revision": "1160321",
      "downloads": {
        "chrome": [
          {
            "platform": "linux64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chrome-linux64.zip"
          },
          {
            "platform": "mac-arm64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-arm64/chrome-mac-arm64.zip"
          },
          {
            "platform": "mac-x64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chrome-mac-x64.zip"
          },
          {
            "platform": "win32",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win32/chrome-win32.zip"
          },
          {
            "platform": "win64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win64/chrome-win64.zip"
          }
        ],
        "chromedriver": [
          {
            "platform": "linux64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip"
          },
          {
            "platform": "mac-arm64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-arm64/chromedriver-mac-arm64.zip"
          },
          {
            "platform": "mac-x64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chromedriver-mac-x64.zip"
          },
          {
            "platform": "win32",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win32/chromedriver-win32.zip"
          },
          {
            "platform": "win64",
            "url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win64/chromedriver-win64.zip"
          }
        ]
      }
    },
    "Beta": ...,
    "Dev": ...,
    "Canary": ...
  }
}

channels 以下に、Stable, Beta, Dev, Canary というバージョンごとの情報がある。

jq でパースするサンプル

Stable バージョン mac-x64 chromedriver のダウンロードURLを取得するサンプル

curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq '.channels.Stable.downloads.chromedriver[] | select(.platform == "mac-x64") | .url'

シェルスクリプトだけで一連のダウンロードをするシェルスクリプト

curl, jq が必要です。

#!/bin/bash -xe

CHROMEDRIVER_BASENAME='chromedriver-mac-x64'
CHROMEDRIVER_ZIP_FILENAME=${CHROMEDRIVER_BASENAME}.zip
CHROMEDRIVER_DOWNLOAD_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform == "mac-x64") | .url')

rm -rf ${CHROMEDRIVER_BASENAME}
echo ${CHROMEDRIVER_DOWNLOAD_URL}
curl -o ${CHROMEDRIVER_ZIP_FILENAME} ${CHROMEDRIVER_DOWNLOAD_URL}
unzip ${CHROMEDRIVER_ZIP_FILENAME}
rm ${CHROMEDRIVER_ZIP_FILENAME}
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?