在本地获取下载chrome,然后离线搬运到 ECS

发布于:2025-09-03 ⋅ 阅读:(17) ⋅ 点赞:(0)

在这里插入图片描述

场景:

  • 阿里云 ECS 无Y网,无法直接拉取 storage.googleapis.com
  • 因此需先在本地里拿到直链并下载,再上传到 ECS。

注:
这个链接是显示近期的几个版本 https://googlechromelabs.github.io/chrome-for-testing/
在这里插入图片描述

这个链接是所有版本 https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
在这里插入图片描述

步骤 1:本地一键获取直链

把下面 10 行 Python 脚本保存为 get_url.py,在本地电脑(已科学上网)运行:

import requests, json, sys

version = sys.argv[1]          # 例:139.0.7258.138
platform = sys.argv[2]         # 例:linux64 / win64 / mac-x64 / mac-arm64

url = "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
data = requests.get(url, timeout=10).json()

for v in data["versions"]:
    if v["version"] == version:
        for item in v["downloads"].get("chrome", []):
            if item["platform"] == platform:
                print(item["url"])
                exit(0)
print("未找到对应版本/平台")

运行示例:

python3 get_url.py 139.0.7258.138 linux64
# 输出:https://storage.googleapis.com/chrome-for-testing-public/139.0.7258.138/linux64/chrome-linux64.zip

步骤 2:本地下载并校验

复制上一步得到的直链,在本地执行:

wget -O chrome-linux64.zip "https://storage.googleapis.com/chrome-for-testing-public/139.0.7258.138/linux64/chrome-linux64.zip"
# 或 curl -L -o chrome-linux64.zip <URL>

步骤 3:上传到 ECS

任选其一:

方式 命令示例
scp scp chrome-linux64.zip root@<ECS_IP>:/tmp/
rsync rsync -avP chrome-linux64.zip root@<ECS_IP>:/tmp/
OSS / COS 先上传到对象存储,再在 ECS 内 wget 内网地址

或直接用 Alibaba cloud client的上传文件/目录的功能,窗口交互式上传文件
在这里插入图片描述

步骤 4:ECS 内解压并部署

ssh root@<ECS_IP>
cd /tmp
unzip -q chrome-linux64.zip
mv chrome-linux64 /opt/chrome/139.0.7258.138
chmod +x /opt/chrome/139.0.7258.138/chrome

常见坑 & 提示

  • 链接 404?99 % 是版本号或平台拼写错误,对照 JSON 再确认。
  • zip 下载不完整?本地先 unzip -t 校验,再上传,避免 ECS 解压失败。
  • 多版本并存?在 ECS 里用软链 /usr/local/bin/chrome-puppeteer 指向所需版本即可。

通过以上流程,即可在无外网 ECS中稳定使用任意历史版本的 Chrome for Testing。


以我之思,AI助力之!


网站公告

今日签到

点亮在社区的每一天
去签到