2015-02-04 5 views
6

Ich möchte die App Kategorie von Play Store durch seine eindeutige Kennung, d. H. Paketname, Ich verwende den folgenden Code, aber keine Daten zurück. Ich habe auch versucht, diese AppsRequest.newBuilder().setAppId(query) immer noch keine Hilfe zu verwenden. Danke.Wie erhalte ich eine App-Kategorie aus dem Play Store nach ihrem Paketnamen in Android?

   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(); 
+0

diese Lösung versuchen: http://stackoverflow.com/a/35903151/2217336 –

Antwort

2

Das ist, was ich tat, beste und einfache Lösung

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

Oder sonst können Sie HTML-Quellcode und erhalten Sie die Zeichenfolge aus bekommen es ...

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

Holen Sie sich diese Zeichenfolge aus - verwenden Sie s plit oder Teilzeichenfolge Methoden

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

In diesem Fall Sport ist Ihre Kategorie

+0

@Salman, aber das gibt mir nicht die app-Kategorie wie Sport, Mode, Lifestyle etc ...? –

+0

@Salman danke für die Hilfe ... :-) –

+0

Hey, es funktioniert gut, aber was, wenn Google Play in einer anderen Sprache ist? Wie bekomme ich nur die englische Version der Kategorie? –

0

Verwendung android-market-api wird es gibt alle Informationen Anwendungs ​​

+0

Ich benutze es bereits, aber es gibt nicht wirklich die Informationen für einen bestimmten Paketnamen, oder ich könnte eine falsche Methode verwenden, können Sie mir mit einem klaren und laufenden Beispiel helfen? –

3

Verwenden Sie dieses Skript:

######## 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) 
+0

Hey, es funktioniert gut, aber was, wenn Google Play in einer anderen Sprache ist? Wie bekomme ich nur die englische Version der Kategorie? –

Verwandte Themen