代码拉取完成,页面将自动刷新
#!/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.')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。