| """Search for applications.""" | |
| from typing import List, Dict | |
| from google_play_scraper.utils.http_utils import get | |
| from google_play_scraper.constants.google_play import SEARCH_URL_FORMAT | |
| from google_play_scraper.constants.element import SEARCH_SELECTORS | |
| def search(query: str, lang: str = "en", country: str = "us", n_hits: int = 20) -> List[Dict]: | |
| """Search apps by query.""" | |
| url = SEARCH_URL_FORMAT.format(query=query, lang=lang, country=country, n_hits=n_hits) | |
| response = get(url) | |
| results = [] | |
| for item in response.get("results", []): | |
| app_data = {} | |
| for key, selector in SEARCH_SELECTORS.items(): | |
| app_data[key] = item.get(selector) | |
| results.append(app_data) | |
| return results |