2 Star 2 Fork 0

Kenny小狼/python-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tomcat_download.py 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
KennyLee 提交于 2017-06-22 19:48 . 增加工具脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author : KennyLee
# Created : 2016-08-11
# Depends : BeautifulSoup4
from sys import argv, exit
from urllib import urlopen, urlretrieve
try:
from bs4 import BeautifulSoup as Soup
except ImportError:
Soup = None
exit("""You need beautifulsoup4!
install it from https://www.crummy.com/software/BeautifulSoup/
or run pip install beautifulsoup4.""")
def get_version():
version = 8
if len(argv) > 1 and argv[1]:
n = None
try:
n = int(argv[1])
except ValueError:
pass
if n and n > 6:
version = n
return version
tomcat_mirrors = 'https://mirrors.tuna.tsinghua.edu.cn'
soup = Soup(urlopen('http://tomcat.apache.org/download-%i0.cgi' % get_version()), "html.parser")
latest_version = soup.select('#content > h3')[4].get_text()
# print latest_version
if latest_version:
url = "%s/apache/tomcat/tomcat-%i/v%s/bin/apache-tomcat-%s.tar.gz" % \
(tomcat_mirrors, get_version(), latest_version, latest_version)
urlretrieve(url, "apache-tomcat-%s.tar.gz" % latest_version)
else:
print('cant find latest version.')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/kennylee/python-tools.git
git@gitee.com:kennylee/python-tools.git
kennylee
python-tools
python-tools
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385