🎨 Extracted common parser string (#285)

This commit is contained in:
Nikhil Badyal
2023-08-15 16:26:08 +05:30
committed by GitHub
parent 86b6770b21
commit d35f93ef77
3 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -12,6 +12,7 @@ from src.patches import Patches
from src.utils import (
apk_mirror_base_url,
apkmirror_status_check,
bs4_parser,
handle_github_response,
)
@@ -28,7 +29,7 @@ def apkcombo_scrapper(package_name: str) -> str:
try:
apkcombo_url = f"https://apkcombo.com/genericApp/{package_name}"
r = requests.get(apkcombo_url, headers=headers, allow_redirects=True)
soup = BeautifulSoup(r.text, "html.parser")
soup = BeautifulSoup(r.text, bs4_parser)
url = soup.select_one("div.avatar > img")["data-src"]
return re.sub(r"=.*$", "", url)
except Exception:
@@ -41,7 +42,7 @@ def apkmirror_scrapper(package_name: str) -> str:
if response["data"][0]["exists"]:
search_url = f"{apk_mirror_base_url}/?s={package_name}"
r = requests.get(search_url, headers=headers)
soup = BeautifulSoup(r.text, "html.parser")
soup = BeautifulSoup(r.text, bs4_parser)
sub_url = soup.select_one("div.bubble-wrap > img")["src"]
new_width = 500
new_height = 500