apksearch 1.2.7__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {apksearch-1.2.7 → apksearch-1.3.0}/PKG-INFO +4 -3
  2. {apksearch-1.2.7 → apksearch-1.3.0}/README.md +1 -1
  3. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/__init__.py +11 -1
  4. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/cli.py +38 -1
  5. apksearch-1.3.0/apksearch/sites/apkmonk.py +108 -0
  6. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/apkpure.py +59 -0
  7. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/aptoide.py +19 -3
  8. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/PKG-INFO +4 -3
  9. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/SOURCES.txt +1 -1
  10. {apksearch-1.2.7 → apksearch-1.3.0}/pyproject.toml +1 -1
  11. {apksearch-1.2.7 → apksearch-1.3.0}/tests/test_apkfab.py +2 -2
  12. apksearch-1.2.7/tests/test_apkcombo.py +0 -38
  13. {apksearch-1.2.7 → apksearch-1.3.0}/LICENSE +0 -0
  14. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/__main__.py +0 -0
  15. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/__init__.py +0 -0
  16. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/apkad.py +0 -0
  17. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/apkcombo.py +0 -0
  18. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/apkfab.py +0 -0
  19. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/apkmirror.py +0 -0
  20. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch/sites/appteka.py +0 -0
  21. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/dependency_links.txt +0 -0
  22. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/entry_points.txt +0 -0
  23. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/requires.txt +0 -0
  24. {apksearch-1.2.7 → apksearch-1.3.0}/apksearch.egg-info/top_level.txt +0 -0
  25. {apksearch-1.2.7 → apksearch-1.3.0}/setup.cfg +0 -0
  26. {apksearch-1.2.7 → apksearch-1.3.0}/tests/test_apkmirror.py +0 -0
  27. {apksearch-1.2.7 → apksearch-1.3.0}/tests/test_apkpure.py +0 -0
  28. {apksearch-1.2.7 → apksearch-1.3.0}/tests/test_appteka.py +0 -0
  29. {apksearch-1.2.7 → apksearch-1.3.0}/tests/test_aptoide.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: apksearch
3
- Version: 1.2.7
3
+ Version: 1.3.0
4
4
  Summary: Search for apks on varius websites
5
5
  Author-email: Abhi <allinoneallinone00@gmail.com>
6
6
  License: MIT License
@@ -49,6 +49,7 @@ Provides-Extra: dev
49
49
  Requires-Dist: pytest>=7.4.3; extra == "dev"
50
50
  Requires-Dist: black>=23.12.1; extra == "dev"
51
51
  Requires-Dist: flake8>=6.1.0; extra == "dev"
52
+ Dynamic: license-file
52
53
 
53
54
  <h1 align="center">apksearch</h1>
54
55
 
@@ -186,7 +187,7 @@ pytest
186
187
  ## Acknowledgements
187
188
 
188
189
  - [APKUpdater](https://github.com/rumboalla/apkupdater) for APKMirror API.
189
- - [apkeep](https://github.com/EFForg/apkeep) for APKPure API.
190
+ ~~- [apkeep](https://github.com/EFForg/apkeep) for APKPure API.~~ (not used anymore)
190
191
 
191
192
  ## License
192
193
 
@@ -134,7 +134,7 @@ pytest
134
134
  ## Acknowledgements
135
135
 
136
136
  - [APKUpdater](https://github.com/rumboalla/apkupdater) for APKMirror API.
137
- - [apkeep](https://github.com/EFForg/apkeep) for APKPure API.
137
+ ~~- [apkeep](https://github.com/EFForg/apkeep) for APKPure API.~~ (not used anymore)
138
138
 
139
139
  ## License
140
140
 
@@ -5,5 +5,15 @@ from .sites.apkcombo import APKCombo
5
5
  from .sites.apkfab import APKFab
6
6
  from .sites.apkad import APKad
7
7
  from .sites.aptoide import Aptoide
8
+ from .sites.apkmonk import APKMonk
8
9
 
9
- __all__ = ["APKPure", "APKMirror", "AppTeka", "APKCombo", "APKFab", "APKad", "Aptoide"]
10
+ __all__ = [
11
+ "APKPure",
12
+ "APKMirror",
13
+ "AppTeka",
14
+ "APKCombo",
15
+ "APKFab",
16
+ "APKad",
17
+ "Aptoide",
18
+ "APKMonk",
19
+ ]
@@ -1,7 +1,16 @@
1
1
  import argparse
2
2
 
3
3
  from collections.abc import Callable
4
- from apksearch import APKPure, APKMirror, AppTeka, APKCombo, APKFab, APKad, Aptoide
4
+ from apksearch import (
5
+ APKPure,
6
+ APKMirror,
7
+ AppTeka,
8
+ APKCombo,
9
+ APKFab,
10
+ APKad,
11
+ Aptoide,
12
+ APKMonk,
13
+ )
5
14
  from requests.exceptions import ConnectionError, ConnectTimeout
6
15
 
7
16
  # Color codes
@@ -191,6 +200,32 @@ def search_aptoide(pkg_name: str, version: str | None) -> None:
191
200
  print(f"{BOLD}Aptoide:{NC} No Results!")
192
201
 
193
202
 
203
+ def search_apkmonk(pkg_name: str, version: str | None) -> None:
204
+ apkmonk = APKMonk(pkg_name)
205
+ try:
206
+ result_apkmonk: tuple[str, str] | None = apkmonk.search_apk()
207
+ except (ConnectionError, ConnectTimeout):
208
+ result_apkmonk = None
209
+ print(f"{RED}Failed to resolve 'apkmonk.com'!{NC}")
210
+ if result_apkmonk:
211
+ title, apk_link = result_apkmonk
212
+ print(f"{BOLD}APKMonk:{NC} Found {GREEN}{title}{NC}") if title else None
213
+ print(f" ╰─> {BOLD}Link: {YELLOW}{apk_link}{NC}") if not version else None
214
+ if version:
215
+ versions: list[tuple[str, str]] = apkmonk.find_versions(apk_link)
216
+ if versions:
217
+ for version_tuple in versions:
218
+ if version_tuple[0] == version:
219
+ print(
220
+ f" ╰─> {BOLD}Version: {GREEN}{version}{NC} - {YELLOW}{version_tuple[1]}{NC}"
221
+ )
222
+ break
223
+ else:
224
+ print(f"{BOLD}APKMonk:{NC} Version {RED}{version}{NC} not found!")
225
+ else:
226
+ print(f"{BOLD}APKMonk:{NC} No Results!")
227
+
228
+
194
229
  def main():
195
230
  parser = argparse.ArgumentParser(
196
231
  prog="APKSearch", description="Search for APKs on various websites"
@@ -220,6 +255,8 @@ def main():
220
255
  search(search_apkfab, pkg_name, version, log_err)
221
256
  # Initiate search on apkad
222
257
  search(search_apkad, pkg_name, version, log_err)
258
+ # Initiate search on apmonk
259
+ search(search_apkmonk, pkg_name, version, log_err)
223
260
 
224
261
 
225
262
  if __name__ == "__main__":
@@ -0,0 +1,108 @@
1
+ import re
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+
5
+
6
+ class APKMonk:
7
+ """
8
+ This class provides methods to search for an APK on APKMonk based on package name,
9
+ and to find available versions and their download links for a given APK link.
10
+
11
+ Parameters:
12
+ pkg_name (str): The package name of the APK to search for.
13
+
14
+ Attributes:
15
+ pkg_name (str): The package name of the APK to search for.
16
+ base_url (str): The base URL of the APKMonk website.
17
+ search_url (str): The URL used to search for APKs on APKMonk.
18
+ headers (dict): The headers used for making HTTP requests.
19
+ session (requests.Session): The session object used for making HTTP requests.
20
+
21
+ Methods:
22
+ search_apk() -> None | tuple[str, str]:
23
+ Searches for the APK on APKMonk and returns the title and link if found.
24
+
25
+ find_versions(apk_link: str) -> list[tuple[str, str]]:
26
+ Finds and returns a list of versions and their download links for the given APK link.
27
+ """
28
+
29
+ def __init__(self, pkg_name: str):
30
+ self.pkg_name = pkg_name
31
+ self.base_url = "https://www.apkmonk.com"
32
+ self.search_url = self.base_url + "/ssearch?q="
33
+ self.headers = {
34
+ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
35
+ "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
36
+ "cache-control": "no-cache",
37
+ "dnt": "1",
38
+ "pragma": "no-cache",
39
+ "priority": "u=0, i",
40
+ "referer": "https://www.apkmonk.com/",
41
+ "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
42
+ "sec-ch-ua-mobile": "?0",
43
+ "sec-ch-ua-platform": '"Windows"',
44
+ "sec-fetch-dest": "document",
45
+ "sec-fetch-mode": "navigate",
46
+ "sec-fetch-site": "same-origin",
47
+ "sec-fetch-user": "?1",
48
+ "upgrade-insecure-requests": "1",
49
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
50
+ }
51
+ self.session = requests.Session()
52
+
53
+ def search_apk(self) -> None | tuple[str, str]:
54
+ """
55
+ Searches for the APK on APKMonk and returns the title and link if found.
56
+
57
+ Returns:
58
+ None: If no matching APK is found.
59
+ tuple[str, str]: A tuple containing the title and link of the matching APK if found.
60
+ """
61
+ pkg_name = self.pkg_name
62
+ url = self.search_url + pkg_name
63
+ response: requests.Response = self.session.get(url, headers=self.headers)
64
+ soup = BeautifulSoup(response.text, "html.parser")
65
+ search_results = soup.find("a", {"title": re.compile(".*apk$")})
66
+ if search_results:
67
+ link = search_results["href"]
68
+ title = search_results.find("span", {"class": "af-title truncate"}).text
69
+ if link == f"/app/{pkg_name}/":
70
+ return title, f"{self.base_url}{link}"
71
+ return None
72
+
73
+ def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
74
+ """
75
+ Finds and returns a list of versions and their download links for the given APK link.
76
+
77
+ Parameters:
78
+ apk_link (str): The link to the APK on the APKMonk website.
79
+
80
+ Returns:
81
+ list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
82
+ and its corresponding download link. If no versions are found, an empty list is returned.
83
+ """
84
+ versions_info = []
85
+ if apk_link.startswith(self.base_url):
86
+ url = apk_link
87
+ response: requests.Response = self.session.get(url, headers=self.headers)
88
+ soup = BeautifulSoup(response.text, "html.parser")
89
+
90
+ version_header = soup.find(
91
+ "div",
92
+ {"class": "box-title"},
93
+ text=re.compile("All Versions", re.IGNORECASE),
94
+ )
95
+
96
+ if version_header:
97
+ versions_table = version_header.find_next("table", {"class": "striped"})
98
+
99
+ if versions_table:
100
+ rows = versions_table.find_all("tr")
101
+ for row in rows:
102
+ version_link = row.find("a", href=True)
103
+ if version_link:
104
+ version_number = version_link.text.strip()
105
+ download_url = self.base_url + version_link["href"]
106
+ versions_info.append((version_number, download_url))
107
+
108
+ return versions_info
@@ -32,6 +32,19 @@ class APKPure:
32
32
  self.cdn_url = "https://d.cdnpure.com/b/APK/"
33
33
  self.cdn_version = "?version="
34
34
  self.search_url = self.base_url + "/search?q="
35
+ self.api_url = "https://tapi.pureapk.com/v3/get_app_his_version"
36
+ self.api_headers = {
37
+ "User-Agent-WebView": "Mozilla/5.0 (Linux; Android 13; Pixel 5 Build/TQ3A.230901.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/132.0.6834.122 Safari/537.36",
38
+ "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 13; Pixel 5 Build/TQ3A.230901.001); APKPure/3.20.34 (Aegon)",
39
+ "Ual-Access-Businessid": "projecta",
40
+ "Ual-Access-ProjectA": """{"device_info":{"abis":["x86_64","arm64-v8a","x86","armeabi-v7a","armeabi"],"android_id":"50f838123d9a9c94","brand":"google","country":"United States","country_code":"US","imei":"","language":"en-US","manufacturer":"Google","mode":"Pixel 5","os_ver":"33","os_ver_name":"13","platform":1,"product":"redfin","screen_height":1080,"screen_width":1920},"host_app_info":{"build_no":"468","channel":"","md5":"6756e53158d6f6c013650a40d8f1147b","pkg_name":"com.apkpure.aegon","sdk_ver":"3.20.34","version_code":3203427,"version_name":"3.20.34"}}""",
41
+ "Ual-Access-ExtInfo": """{"ext_info":"{\"gaid\":\"\",\"oaid\":\"\"}","lbs_info":{"accuracy":0.0,"city":"","city_code":0,"country":"","country_code":"","district":"","latitude":0.0,"longitude":0.0,"province":"","street":""}}""",
42
+ "Ual-Access-Sequence": "",
43
+ "Ual-Access-Nonce": "21448252",
44
+ "Ual-Access-Timestamp": "1738560597165",
45
+ "Connection": "Keep-Alive",
46
+ "Accept-Encoding": "gzip",
47
+ }
35
48
  self.headers = {
36
49
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
37
50
  "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
@@ -52,6 +65,40 @@ class APKPure:
52
65
  }
53
66
  self.session = requests.Session()
54
67
 
68
+ def _api_search(self) -> None | tuple[str, list[tuple[str, str]]]:
69
+ """
70
+ Attempts to fetch app information using API.
71
+
72
+ Returns:
73
+ None: If API request fails or no data found
74
+ tuple[str, list[tuple[str, str]]]: App title and list of (version, download_url) tuples
75
+ """
76
+ try:
77
+ params = {"package_name": self.pkg_name, "hl": "en"}
78
+ response = self.session.get(
79
+ self.api_url, headers=self.api_headers, params=params
80
+ )
81
+ data = response.json()
82
+
83
+ if not data.get("version_list"):
84
+ return None
85
+
86
+ versions_info = []
87
+ title = None
88
+
89
+ for version in data["version_list"]:
90
+ version_name = version["version_name"]
91
+ if not title:
92
+ title = version["title"]
93
+ if version.get("asset", {}).get("urls"):
94
+ download_url = version["asset"]["urls"][0]
95
+ versions_info.append((version_name, download_url))
96
+
97
+ return (title, versions_info) if title and versions_info else None
98
+
99
+ except Exception:
100
+ return None
101
+
55
102
  def search_apk(self) -> None | tuple[str, str]:
56
103
  """
57
104
  Searches for the APK on APKPure and returns the title and link if found.
@@ -60,6 +107,14 @@ class APKPure:
60
107
  None: If no matching APK is found.
61
108
  tuple[str, str]: A tuple containing the title and link of the matching APK if found.
62
109
  """
110
+ # Try API first
111
+ api_result = self._api_search()
112
+ if api_result:
113
+ title, versions = api_result
114
+ if versions:
115
+ return title, versions[0][1]
116
+
117
+ # Fall back to web scrapping
63
118
  pkg_name = self.pkg_name
64
119
  url = self.search_url + pkg_name
65
120
  response: requests.Response = self.session.get(url, headers=self.headers)
@@ -110,6 +165,10 @@ class APKPure:
110
165
  list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
111
166
  and its corresponding download link. If no versions are found, an empty list is returned.
112
167
  """
168
+ api_result = self._api_search()
169
+ if api_result:
170
+ return api_result[1]
171
+
113
172
  versions_info = []
114
173
  if apk_link.startswith(self.base_url):
115
174
  url = apk_link + "/versions"
@@ -29,7 +29,7 @@ class Aptoide:
29
29
  def __init__(self, pkg_name: str):
30
30
  self.pkg_name = pkg_name
31
31
  self.api_url = "https://ws75.aptoide.com/api/7"
32
- self.search_url = f"{self.api_url}/apps/search?limit=1&query="
32
+ self.search_url = f"{self.api_url}/apps/search"
33
33
  self.headers = {
34
34
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
35
35
  "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
@@ -48,6 +48,20 @@ class Aptoide:
48
48
  "upgrade-insecure-requests": "1",
49
49
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
50
50
  }
51
+ self.params = {
52
+ "cdn": "web",
53
+ "q": "bXlDUFU9YXJtNjQtdjhhLGFybWVhYmktdjdhLGFybWVhYmkmbGVhbmJhY2s9MA",
54
+ "aab": "1",
55
+ "mature": "false",
56
+ "language": "en_US",
57
+ "country": "US",
58
+ "not_apk_tags": "",
59
+ "query": self.pkg_name,
60
+ "limit": "1",
61
+ "offset": "0",
62
+ "origin": "SITE",
63
+ "store_name": "aptoide-web",
64
+ }
51
65
  self.session = requests.Session()
52
66
 
53
67
  def search_apk(self) -> None | tuple[str, str]:
@@ -59,8 +73,10 @@ class Aptoide:
59
73
  tuple[str, str]: A tuple containing the title and link of the matching APK if found.
60
74
  """
61
75
  pkg_name = self.pkg_name
62
- url = self.search_url + pkg_name
63
- response: requests.Response = self.session.get(url, headers=self.headers)
76
+ url = self.search_url
77
+ response: requests.Response = self.session.get(
78
+ url, headers=self.headers, params=self.params
79
+ )
64
80
  data = response.json()
65
81
  if data and data["info"]["status"] == "OK":
66
82
  lis = data["datalist"]["list"]
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: apksearch
3
- Version: 1.2.7
3
+ Version: 1.3.0
4
4
  Summary: Search for apks on varius websites
5
5
  Author-email: Abhi <allinoneallinone00@gmail.com>
6
6
  License: MIT License
@@ -49,6 +49,7 @@ Provides-Extra: dev
49
49
  Requires-Dist: pytest>=7.4.3; extra == "dev"
50
50
  Requires-Dist: black>=23.12.1; extra == "dev"
51
51
  Requires-Dist: flake8>=6.1.0; extra == "dev"
52
+ Dynamic: license-file
52
53
 
53
54
  <h1 align="center">apksearch</h1>
54
55
 
@@ -186,7 +187,7 @@ pytest
186
187
  ## Acknowledgements
187
188
 
188
189
  - [APKUpdater](https://github.com/rumboalla/apkupdater) for APKMirror API.
189
- - [apkeep](https://github.com/EFForg/apkeep) for APKPure API.
190
+ ~~- [apkeep](https://github.com/EFForg/apkeep) for APKPure API.~~ (not used anymore)
190
191
 
191
192
  ## License
192
193
 
@@ -15,10 +15,10 @@ apksearch/sites/apkad.py
15
15
  apksearch/sites/apkcombo.py
16
16
  apksearch/sites/apkfab.py
17
17
  apksearch/sites/apkmirror.py
18
+ apksearch/sites/apkmonk.py
18
19
  apksearch/sites/apkpure.py
19
20
  apksearch/sites/appteka.py
20
21
  apksearch/sites/aptoide.py
21
- tests/test_apkcombo.py
22
22
  tests/test_apkfab.py
23
23
  tests/test_apkmirror.py
24
24
  tests/test_apkpure.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "apksearch"
7
- version = "1.2.7"
7
+ version = "1.3.0"
8
8
  description = "Search for apks on varius websites"
9
9
  authors = [{ name = "Abhi", email = "allinoneallinone00@gmail.com" }]
10
10
  license = { file = "LICENSE" }
@@ -2,7 +2,7 @@ from apksearch.sites.apkfab import APKFab
2
2
 
3
3
 
4
4
  def test_search_apk():
5
- query = "com.roblox.client"
5
+ query = "com.facebook.katana"
6
6
  apkfab = APKFab(query)
7
7
  result = apkfab.search_apk()
8
8
 
@@ -14,7 +14,7 @@ def test_search_apk():
14
14
 
15
15
 
16
16
  def test_find_versions():
17
- query = "com.roblox.client"
17
+ query = "com.facebook.katana"
18
18
  apkfab = APKFab(query)
19
19
  result = apkfab.search_apk()
20
20
 
@@ -1,38 +0,0 @@
1
- from apksearch.sites.apkcombo import APKCombo
2
-
3
-
4
- def test_search_apk():
5
- query = "com.roblox.client"
6
- apkcombo = APKCombo(query)
7
- result = apkcombo.search_apk()
8
-
9
- assert result is not None, "No APK found for the query."
10
- assert isinstance(result, tuple), "Result should be a tuple."
11
- assert len(result) == 2, "Tuple should contain two elements."
12
- assert isinstance(result[0], str), "First element of the tuple should be a string."
13
- assert isinstance(result[1], str), "Second element of the tuple should be a string."
14
-
15
-
16
- def test_find_versions():
17
- query = "com.roblox.client"
18
- apkcombo = APKCombo(query)
19
- result = apkcombo.search_apk()
20
-
21
- if result:
22
- apk_link = result[1]
23
- versions = apkcombo.find_versions(apk_link)
24
-
25
- assert isinstance(versions, list), "Versions should be a list."
26
- assert len(versions) > 0, "No versions found."
27
- assert all(
28
- isinstance(version, tuple) for version in versions
29
- ), "Each version should be a tuple."
30
- assert all(
31
- len(version) == 2 for version in versions
32
- ), "Each version tuple should contain two elements."
33
- assert all(
34
- isinstance(version[0], str) for version in versions
35
- ), "First element of each version tuple should be a string."
36
- assert all(
37
- isinstance(version[1], str) for version in versions
38
- ), "Second element of each version tuple should be a string."
File without changes
File without changes