我正在寻找一个链接来获取 Microsoft Edge 的最新驱动程序版本号,类似于 Google Chrome 的链接:https://chromedriver.storage.googleapis.com/LATEST_RELEASE
我有一个返回版本号字符串的函数。然后,我可以像这样创建一个下载链接:
private String getLatestChromeDriverVersion(){
RestTemplate restTemplate = new RestTemplate();
String url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE";
return restTemplate.getForObject(url, String.class);
}
String chromeDownloadUrl = "https://chromedriver.storage.googleapis.com/" + getLatestChromeDriverVersion() + "/chromedriver_win32.zip";
我一直在寻找与 Edge 类似的东西,但我找不到任何东西。他们有这个页面用于下载驱动程序:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/但没有像/latest或/stable这样的页面。
有什么想法吗?
您可以通过这两个链接获取官方文档中给出的最新版本号:
https://msedgedriver.azureedge.net/LATEST_STABLE
和
https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_STABLE
注意:它们都是返回一个文件,而不是像chrome那样直接返回版本号,你需要从这个文件中获取版本号。
一个简单的演示:
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://msedgedriver.azureedge.net/LATEST_STABLE"))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
String version = response.body().replaceAll("[^\\d|.]", "");
System.out.println(version);
您可以获取 JSON 格式的最新 Edge 版本。它具有针对每个平台和体系结构的按渠道(产品)的最新版本。
消费者版本:(Windows、MacOS、Linux、Android、IOS)
https://edgeupdates.microsoft.com/api/products
企业版本:(Windows、MacOS、Linux、GPO 策略文件)
https://edgeupdates.microsoft.com/api/products?view=enterprise
构建分为多个渠道(稳定版、测试版、开发版、金丝雀版)
示例:
{
"Product": "Dev",
"Releases": [
{
"ReleaseId": 43248,
"Platform": "MacOS",
"Architecture": "universal",
"CVEs": [],
"ProductVersion": "110.0.1587.2",
"Artifacts": [
{
"ArtifactName": "pkg",
"Location": "https://officecdnmac.microsoft.com/pr/03adf619-38c6-4249-95ff-4a01c0ffc962/MacAutoupdate/MicrosoftEdgeDev-110.0.1587.2.pkg",
"Hash": "046BB1322257530A66BCCEC6E821F2548163BEC1818C85B6FEB1E986DB62EBC0",
"HashAlgorithm": "SHA256",
"SizeInBytes": 352551023
},
{
"ArtifactName": "plist",
"Location": "https://officecdnmac.microsoft.com/pr/03adf619-38c6-4249-95ff-4a01c0ffc962/MacAutoupdate/MicrosoftEdgeDev-110.0.1587.2.plist",
"Hash": "4C8EB411D4A93FB721FF7A90031C95D696E97BB2D9051C48501C0BEB12AFBB19",
"HashAlgorithm": "SHA256",
"SizeInBytes": 3053
}
],
"PublishedTime": "2023-01-05T19:43:00",
"ExpectedExpiryDate": "2023-04-05T19:43:00"
},
{
"ReleaseId": 43170,
"Platform": "Windows",
"Architecture": "x64",
"CVEs": [],
"ProductVersion": "110.0.1587.1",
"Artifacts": [
{
"ArtifactName": "msi",
"Location": "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/4de84b50-b3a8-4751-afb8-73812bce8713/MicrosoftEdgeDevEnterpriseX64.msi",
"Hash": "4DC76967D9BA3BFDB275B8D40AE3A9ED7F77C661879BFC1CD6C4264EBDC09540",
"HashAlgorithm": "SHA256",
"SizeInBytes": 147148800
}
],
"PublishedTime": "2023-01-04T20:22:00",
"ExpectedExpiryDate": "2023-04-04T20:22:00"
}
]
}
}
彭旭东的回答是正确的。 我想补充一点,您可以通过此链接获取某个主要版本的最新版本:
https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_RELEASE_<MAJOR_VERSION>
再次返回一个文件,您需要解析该文件才能获取最新版本。
如果像我的情况一样,您的 Edge 浏览器不是最新版本,并且您想要检索该版本的最新 Edgedriver,则这非常有用。
好的,所以我注意到输出是一个文件,然后我调整输出以用作变量中的字符串。这是在
linux shell
: 中获取最新版本 URL 的方法
curl https://msedgedriver.azureedge.net/LATEST_STABLE | iconv -f UTF-16 -t UTF-8 | tr -d '\r'
现在,变量
LATEST_VERSION
仅返回版本号:
$ echo $LATEST_VERSION
126.0.2592.68
现在,您可以使用该变量来下载 EdgeDriver 本身
# get version
LATEST_VERSION=$(curl https://msedgedriver.azureedge.net/LATEST_STABLE | iconv -f UTF-16 -t UTF-8 | tr -d '\r')
# download from `azureedge.net`
wget https://msedgedriver.azureedge.net/$LATEST_VERSION/edgedriver_linux64.zip
如果您像我一样正在构建容器,则可以将 Edgedriver 可执行文件保存到您的
$PATH
位置之一,例如 /usr/local/bin`
LATEST_VERSION=$(curl https://msedgedriver.azureedge.net/LATEST_STABLE | iconv -f UTF-16 -t UTF-8 | tr -d '\r') && \
wget https://msedgedriver.azureedge.net/$LATEST_VERSION/edgedriver_linux64.zip && \
unzip edgedriver_linux64.zip -d /usr/local/bin && \
rm edgedriver_linux64.zip