場景:
- 阿里云 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, sysversion = sys.argv[1] # 例:139.0.7258.138
platform = sys.argv[2] # 例:linux64 / win64 / mac-x64 / mac-arm64url = "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助力之!