Skip to content
Merged

Dev #181

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aktools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
0.0.86: add: add log function
0.0.87: fix: fix update python 3.13
0.0.88: fix: fix update typer deps
0.0.89: fix: fix get_latest_version
"""

__title__ = "AKTools"
__version__ = "0.0.88"
__version__ = "0.0.89"
__author__ = "AKFamily"
19 changes: 9 additions & 10 deletions aktools/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding:utf-8 -*-
# !/usr/bin/env python
"""
Date: 2022/9/27 21:58
Date: 2024/12/12 18:00
Desc: 工具函数
"""
from functools import lru_cache

import requests
from bs4 import BeautifulSoup


@lru_cache()
Expand All @@ -20,15 +19,15 @@ def get_latest_version(package: str = "akshare") -> str:
:return: 版本
:rtype: str
"""
url = f"https://pypi.org/project/{package}"
url = f"https://pypi.org/pypi/{package}/json"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/58.0.3029.110 Safari/537.3"
}
try:
r = requests.get(url, verify=False)
r = requests.get(url, headers=headers)
except requests.exceptions.ProxyError:
return "0.0.0"
soup = BeautifulSoup(r.text, "lxml")
version = (
soup.find("h1", attrs={"class": "package-header__name"})
.text.strip()
.split(" ")[1]
)
data_json = r.json()
version = data_json['info']['version']
return version
2 changes: 2 additions & 0 deletions docs/aktools_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

## 开发进度

0.0.89: fix: fix get_latest_version

0.0.88: fix: fix update typer deps

0.0.87: fix: fix update python 3.13
Expand Down
Loading