Created
September 12, 2023 06:02
-
-
Save Vinfall/ee185e21181221157362dbe8b1a2107d to your computer and use it in GitHub Desktop.
Check update from CoolAPK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# Author: Vinfall | |
# License: GNU GPL v3.0 | |
from bs4 import BeautifulSoup as bs | |
import requests | |
base_url = 'https://www.coolapk.com/apk/' | |
package_name = ['me.gfuil.bmap'] | |
app_name = ["Bmap 白马地图"] | |
ver = ["7.230809.Final"] | |
def check_update(index): | |
headers = { | |
'Host': 'www.coolapk.com', | |
# 'Referer': 'https://www.coolapk.com/apk/tag/%E9%93%B6%E8%A1%8C', | |
'User-Agent': '"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"', | |
'Connection': 'keep-alive', | |
} | |
url = base_url + package_name[index] | |
source = requests.get(url, headers=headers).content | |
soup = bs(source, 'lxml', from_encoding='utf-8') | |
# print(soup) | |
# tags = soup.title.string | |
# tags = soup.find("p", class_="detail_app_title") | |
# Bmap 白马地图(me.gfuil.bmap) - 7.6.87 - 应用 - 酷安网 | |
# ^ ^ ^ | |
# 0...........................-11....................-1 | |
# print(tags[0:-11]) | |
# realver = tags[0:-11] | |
tag = soup.find("span", class_="list_app_info") | |
vers= tag.string | |
# print(tag) | |
# 7.230809.Final | |
# ^ ^ ^ | |
# 0.2............-1 | |
realver = vers[2:] | |
# print(realver) | |
if realver != ver[index]: | |
# print(ver[index] + ' has a newer version!') | |
print(app_name[index] + ': ' + ver[index] + ' -> ' + realver) | |
if __name__ == '__main__': | |
for i in range(len(package_name)): | |
check_update(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment