diff --git a/requirements.txt b/requirements.txt index 3b84c02..6bd9596 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ beautifulsoup4==4.12.2 environs==9.5.0 +google-play-scraper==1.2.4 lastversion==3.0.1 loguru==0.7.0 pre-commit==3.3.3 diff --git a/scripts/status_check.py b/scripts/status_check.py index d77e198..25ae44b 100644 --- a/scripts/status_check.py +++ b/scripts/status_check.py @@ -2,7 +2,7 @@ from typing import List import requests -from bs4 import BeautifulSoup +from google_play_scraper import app as gplay_app from src.patches import Patches from src.utils import handle_response @@ -14,13 +14,12 @@ def gplay_icon_scrapper(package_name: str) -> str: """Scrap Icon from Gplay.""" # noinspection PyBroadException try: - app_url = ( - f"https://play.google.com/store/apps/details?id={package_name}&hl=en&gl=US" + result = gplay_app( + package_name, ) - response = requests.get(app_url) - soup = BeautifulSoup(response.text, "html.parser") - icon = soup.select_one("div.Il7kR > img") - return str(icon["srcset"].split(" ")[0]) + if not result["icon"]: + raise ValueError() + return str(result["icon"]) except Exception: return not_found_icon @@ -30,14 +29,16 @@ def generate_markdown_table(data: List[List[str]]) -> str: if len(data) == 0: return "No data to generate table." - table = "| Package Name | PlayStore link | APKMirror link| Supported ?|\n" - table += "|-------------|----------------|---------------|------------|\n" + table = "| Package Name | App Icon | PlayStore link | APKMirror link| Supported?|\n" + table += ( + "|-------------|----------|----------------|---------------|------------|\n" + ) for row in data: - if len(row) != 3: + if len(row) != 5: raise ValueError("Each row must contain 4 columns of data.") - table += f"| {row[0]} | {row[1]} | {row[2]} |