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

在这里插入图片描述

场景:

  • 阿里云 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

任选其一:

方式命令示例
scpscp chrome-linux64.zip root@<ECS_IP>:/tmp/
rsyncrsync -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助力之!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值