Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!/usr/bin/env python3
import os
from urllib.parse import urlparse, parse_qs
from playstore.playstore import Playstore
def main():
# Use the private credentials for this script.
api = Playstore(
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
os.path.pardir,
"private_credentials.json",
)
)
# Get the categories in the Google Play Store.
res = api.protobuf_to_dict(api.get_store_categories())["category"]
store_categories = set(
map(lambda x: parse_qs(urlparse(x["dataUrl"]).query).get("cat", [None])[0], res)
)
# Get the top top_num free apps in each category.
top_num = 10
for cat in store_categories:
if not cat:
continue
doc = api.list_app_by_category(cat, "apps_topselling_free", top_num).doc[0]
for app in doc.child if doc.docid else doc.child[0].child:
rating = app.aggregateRating.starRating
# Print package name, category and rating.
print(f"{app.docid}|{cat}|{rating}")
if __name__ == "__main__":
# Run the script from the main directory of the project by using this command:
# pipenv run python -m scripts.crawl_top_apps_by_category
main()