我想在 python 上查询 MS teams 下载站点以获得最新版本
I would like to query MS teams download site for the latest version on python
我想在 python 上查询 MS teams 下载站点以获得最新版本,我正在使 MS teams 自动化以单击“修复”,它会自行重新安装我的程序 运行。
不过我现在正在使用静态 link,我想知道有没有办法查询最新版本,这样当我请求 运行 时,我可以拥有要求获取最新版本而不是依赖必须手动更新的静态 link 的参数。
如有任何帮助,我们将不胜感激。
if os.path.exists("C:/Users/%s/AppData/Local/Microsoft/Teams" %Name):
print("installed, please close teams and rerun this program.")
time.sleep(10)
else:
url = 'https://statics.teams.cdn.office.net/production-windows-x64/1.4.00.19572/Teams_windows_x64.exe'
response = requests.get(url, stream=True)
total_size_in_bytes= int(response.headers.get('content-length', 0))
block_size = 1024
progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
with open('c:/users/%s/downloads/Teams.exe' %Name, 'wb') as file:
for data in response.iter_content(block_size):
progress_bar.update(len(data))
file.write(data)
progress_bar.close()
if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
print("ERROR: Something went wrong, check connection and try again, or see help.txt for more info")
time.sleep(10)
我可能没有解释清楚,但是request函数用的是静态的link,有没有办法只能去下载站查询最新版本,基本上问一下就可以了要重新安装最新版本的团队,否则我必须在团队更新时手动更新 link。
这是下载并显示进度条的代码片段,其中 url = "static link" 我想获得一种自动插入最新 links 的方法.
我的脚本可以重新安装团队并显示进度条程序本身没有错误只是想改进它以供普遍使用。
我最后的选择是使用 update.exe 团队用来获取最新版本的文件,但我不希望它依赖于脚本文件夹中本地存在的任何 .exe,而只是代码应该完成任务。
else:
os.system('cmd /k "winget install Microsoft.Teams"')
print("installed, Exiting in 10 seconds")
time.sleep(10)
好吧,在了解了 winget 以及如何在 python 中使用它之后,我将代码减半,解决了我的问题,现在我可以随时下载带有 cmd 反馈的最新团队,而不是使用静态源并编写我自己的进度条。
如果您导航到 https://teams.microsoft.com/desktopclient/installer/windows/x64,它将 return 最新包的 url
我想在 python 上查询 MS teams 下载站点以获得最新版本,我正在使 MS teams 自动化以单击“修复”,它会自行重新安装我的程序 运行。
不过我现在正在使用静态 link,我想知道有没有办法查询最新版本,这样当我请求 运行 时,我可以拥有要求获取最新版本而不是依赖必须手动更新的静态 link 的参数。
如有任何帮助,我们将不胜感激。
if os.path.exists("C:/Users/%s/AppData/Local/Microsoft/Teams" %Name):
print("installed, please close teams and rerun this program.")
time.sleep(10)
else:
url = 'https://statics.teams.cdn.office.net/production-windows-x64/1.4.00.19572/Teams_windows_x64.exe'
response = requests.get(url, stream=True)
total_size_in_bytes= int(response.headers.get('content-length', 0))
block_size = 1024
progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
with open('c:/users/%s/downloads/Teams.exe' %Name, 'wb') as file:
for data in response.iter_content(block_size):
progress_bar.update(len(data))
file.write(data)
progress_bar.close()
if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
print("ERROR: Something went wrong, check connection and try again, or see help.txt for more info")
time.sleep(10)
我可能没有解释清楚,但是request函数用的是静态的link,有没有办法只能去下载站查询最新版本,基本上问一下就可以了要重新安装最新版本的团队,否则我必须在团队更新时手动更新 link。
这是下载并显示进度条的代码片段,其中 url = "static link" 我想获得一种自动插入最新 links 的方法.
我的脚本可以重新安装团队并显示进度条程序本身没有错误只是想改进它以供普遍使用。
我最后的选择是使用 update.exe 团队用来获取最新版本的文件,但我不希望它依赖于脚本文件夹中本地存在的任何 .exe,而只是代码应该完成任务。
else:
os.system('cmd /k "winget install Microsoft.Teams"')
print("installed, Exiting in 10 seconds")
time.sleep(10)
好吧,在了解了 winget 以及如何在 python 中使用它之后,我将代码减半,解决了我的问题,现在我可以随时下载带有 cmd 反馈的最新团队,而不是使用静态源并编写我自己的进度条。
如果您导航到 https://teams.microsoft.com/desktopclient/installer/windows/x64,它将 return 最新包的 url