吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1448|回复: 4
收起左侧

[Python 原创] VSCode半自动下载最新版脚本(不含Mac、32位版本)以及1.83.0的加速下载地址汇总

[复制链接]
我心飞翔1995 发表于 2023-10-5 22:14
日常有搜集软件特定版本的习惯,加上自己配了一个绿色版的VSCode,每次更新需要下载最新的绿色版本来覆盖更新,但是官方地址比较慢,便融合网上检测VSCode更新地址的代码,加上自己需要下载的文件的地址,完成了如下代码。分享出来方便有类似习惯的小伙伴,或者需要给离线机器更新的运维朋友。
原理是通过GitHub的api检测最新的release,基于正则匹配识别出commit id,然后将commit id套用到微软下载地址模板中,再触发浏览器的下载,如果开了自动下载的话无需手动,没开的需要手动点一下。
能看懂代码的可以自己改,加上更多功能,我就到这一步可以了,懒得再加更多。看不懂的话,使用python运行之后,看到提示就输入y(一共两次)。实在不会的,用成品地址汇总自己替换commit id部分。
PS:代码和截图包含小福利,是官方没有直接首页放置下载入口的产品,喜欢的可以自己下载体验。

代码如下:
[Python] 纯文本查看 复制代码
import webbrowser
import time
import requests
import re
import sys

repo_url = 'https://api.github.com/repos/microsoft/vscode/releases/latest'

version = requests.get(repo_url).json()['tag_name']
answer = input(f'Latest Version is {version},Upgrade(y or n)?')
if answer == 'n':
	sys.exit()

release_url = requests.get(repo_url).json()['html_url']
commit_id = (re.search('href=\"/microsoft/vscode/commit/(.+?)\"',requests.get(release_url).text).group(1))

server_urls = [
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-linux-x64/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-win32-x64/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-alpine-arm64/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-linux-arm64/stable',6)
]
server_web_urls = [
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-linux-x64-web/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-win32-x64-web/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-alpine-arm64-web/stable',6),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/server-linux-arm64-web/stable',6)
]
bin_urls = [
	(f'https://update.code.visualstudio.com/commit:{commit_id}/cli-win32-x64/stable',2),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/cli-win32-arm64/stable',2),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/cli-alpine-x64/stable',2),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/cli-alpine-arm64/stable',2),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-x64-user/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-arm64-user/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-x64/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-arm64/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-x64-archive/stable',14),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/win32-arm64-archive/stable',14),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-deb-x64/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-deb-arm64/stable',10),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-rpm-x64/stable',14),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-rpm-arm64/stable',14),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-x64/stable',14),
	(f'https://update.code.visualstudio.com/commit:{commit_id}/linux-arm64/stable',14)
	]

answer2 = input(f'Download(y or n)?choose n to print urls and write them into urls.txt:')
if answer2 == 'n':
	str1 = '\n'.join([ i[0] for i in server_urls])
	str2 = '\n'.join([ i[0] for i in server_web_urls])
	str3 = '\n'.join([ i[0] for i in bin_urls])
	output = f'''vscode server's urls are:
{str1}
vscode server web's urls are:
{str2}
vscode bin's urls are:
{str3}'''
	with open(r'./urls.txt','w') as f:
		f.write(output)
	print(output)
	sys.exit()

for url,wait_time in bin_urls:
    webbrowser.open_new_tab(url)
    time.sleep(wait_time)
    
for url,wait_time in server_urls:
    webbrowser.open_new_tab(url)
    time.sleep(wait_time)
    
for url,wait_time  in server_web_urls:
    webbrowser.open_new_tab(url)
    time.sleep(wait_time)

运行截图:
QQ截图20231005220136.png
QQ截图20231005220136.png
附送1.83.0的地址汇总,后续版本需要的可以自己手动替换commit id更新,本帖不更新后续版本地址。
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/cli-win32-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/cli-win32-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/cli-alpine-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/cli-alpine-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-x64-user/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-arm64-user/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-x64-archive/stable(windows x86的64位绿色版)
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/win32-arm64-archive/stable (windows arm的64位绿色版)
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-deb-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-deb-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-rpm-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-rpm-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-x64/stable (linux x86的64位绿色版)
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/linux-arm64/stable (linux arm的64位绿色版)
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-linux-x64-web/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-win32-x64-web/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-alpine-arm64-web/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-linux-arm64-web/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-linux-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-win32-x64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-alpine-arm64/stable
https://update.code.visualstudio.com/commit:e7e037083ff4455cf320e344325dacb480062c3c/server-linux-arm64/stable

免费评分

参与人数 1吾爱币 +5 热心值 +1 收起 理由
苏紫方璇 + 5 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

my2003sky 发表于 2023-10-6 21:09
多谢分享。
zwl0929 发表于 2023-10-16 10:03
plutos77 发表于 2023-10-24 12:44
aqimo 发表于 2023-11-19 00:19
学习一下自动化
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 21:59

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表