How to get the App category from a play store by the name of its package in Android?

I want to get the application category from the play store through my unique identifier, i.e. package name . I am using the following code but not returning any data. I also tried using this AppsRequest.newBuilder().setAppId(query) until I helped. Thanks.

  String AndroidId = "dead000beef"; MarketSession session = new MarketSession(); session.login("email", "passwd"); session.getContext().setAndroidId(AndroidId); String query = "package:com.king.candycrushsaga"; AppsRequest appsRequest = AppsRequest.newBuilder().setQuery(query).setStartIndex(0) .setEntriesCount(10).setWithExtendedInfo(true).build(); session.append(appsRequest, new Callback<AppsResponse>() { @Override public void onResult(ResponseContext context, AppsResponse response) { String response1 = response.toString(); Log.e("reponse", response1); } }); session.flush(); 
+6
source share
3 answers

This is what I did, the best and easiest solution

 https://androidquery.appspot.com/api/market?app=your.unique.package.name 

Or else you can get the original html and get a string from it ...

 https://play.google.com/store/apps/details?id=your.unique.package.name 

Extract this string from it - use split methods or substrings

 <span itemprop="genre">Sports</span> 

In this case, sport is your category.

+2
source

Use this script:

 ######## Fetch App names and genre of apps from playstore url, using pakage names ############# """ Reuirements for running this script: 1. requests library Note: Run this command to avoid insecureplatform warning pip install --upgrade ndg-httpsclient 2. bs4 pip install requests pip install bs4 """ import requests import csv from bs4 import BeautifulSoup # url to be used for package APP_LINK = "https://play.google.com/store/apps/details?id=" output_list = []; input_list = [] # get input file path print "Need input CSV file (absolute) path \nEnsure csv is of format: <package_name>, <id>\n\nEnter Path:" input_file_path = str(raw_input()) # store package names and ids in list of tuples with open(input_file_path, 'rb') as csvfile: for line in csvfile.readlines(): (p, i) = line.strip().split(',') input_list.append((p, i)) print "\n\nSit back and relax, this might take a while!\n\n" for package in input_list: # generate url, get html url = APP_LINK + package[0] r = requests.get(url) if not (r.status_code==404): data = r.text soup = BeautifulSoup(data, 'html.parser') # parse result x = ""; y = ""; try: x = soup.find('div', {'class': 'id-app-title'}) x = x.text except: print "Package name not found for: %s" %package[0] try: y = soup.find('span', {'itemprop': 'genre'}) y = y.text except: print "ID not found for: %s" %package[0] output_list.append([x,y]) else: print "App not found: %s" %package[0] # write to csv file with open('results.csv', 'w') as fp: a = csv.writer(fp, delimiter=",") a.writerows(output_list) 
+3
source

use android-market-api , it will provide all the information about the application

0
source

Source: https://habr.com/ru/post/981975/


All Articles