#packageName = "com.WiredDFW.DIRECTV.unWiredRemoteLite" #Default value
#packageName = "com.happybug.livewallpaper.jellyfishlite"
print "Nextline:", packageName
filterByDevice=False
sort=0


api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

#response = api.reviewById(packageName, filterByDevice, ID)
#print response
for s in range(4):
    sort = s
    for m in range(MAX_RESULTS/NB_RES):
        response = api.reviews(packageName, filterByDevice, sort, str(NB_RES),str(m*NB_RES))
#        print response
        for n in range(NB_RES):
            try:
                c = response.getResponse.review[n]
                l = [  

                           c.documentVersion,
                           
                           c.timestampMsec,

                           c.starRating,
                           c.title,
                           c.comment,
                           c.commentId,
예제 #2
0
if (len(sys.argv) < 2):
    print "Usage: %s request [package] [offset]" % sys.argv[0]
    print "Returns 20 reviews for a given app package."
    sys.exit(0)

request = sys.argv[1]
nb_res = 20
offset = 0

if (len(sys.argv) >= 3):
    offset = int(sys.argv[2])

api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

try:
    reviews = api.reviews(request, False, 0, nb_res, offset)
except:
    print "Error: something went wrong. Maybe the nb_res you specified was too big?"
    sys.exit(1)

resp = reviews.getResponse
print_header_line()
try:
	for c in resp.review:
	    if c != None:
	        print_result_line(c)
except Exception,e:
	print e

예제 #3
0
def getReviews(packageName,pip):
    NB_RES = 20;
    MAX_RESULTS = 500;
    #packageName = "com.WiredDFW.DIRECTV.unWiredRemoteLite" #Default value
    #packageName = "com.happybug.livewallpaper.jellyfishlite"
    print "Nextline:", packageName
    filterByDevice=False
    sort=0


    api = GooglePlayAPI(ANDROID_ID)
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN,pip)

    #response = api.reviewById(packageName, filterByDevice, ID)
    #print response
    for s in range(4):
        sort = s
        time.sleep(3)
        for m in range(MAX_RESULTS/NB_RES):
            time.sleep(1)
            response = api.reviews(packageName, filterByDevice, sort, str(NB_RES),str(m*NB_RES),pip=pip)
    #        print response
            for n in range(NB_RES):
                try:
                    c = response.getResponse.review[n]
                    l = [  
                               
                               c.documentVersion,
                               
                               c.timestampMsec,
                               
                               c.starRating,
                               c.title,
                               c.comment,
                               c.commentId,
                               
                               c.deviceName,
#                               c.replyText,
#                               c.replyTimestampMsec, 
                               ]

                    #Check whether comment exists
                    fileName = "%d.%s.csv" %(s,packageName)
                    openfile = open(fileName,"a+")
                  
                    previousFileName = "previous.%s.csv" %packageName 
                    openPreviousFile = open(previousFileName,"a+")
                  
                    if hasInFile(openfile,c.commentId, c.timestampMsec) or hasInFile(openPreviousFile,c.commentId,c.timestampMsec):
                        openfile.close()
                        openPreviousFile.close()
                        continue
                    else:
                        print "There is new review of s = %d m = %d n = %d" %(s,m,n)
                        saveFile = open(fileName, "a+b")
                        savePreviousFile = open(previousFileName, "a+b")
                        wpb = UnicodeWriter(savePreviousFile)
                        wb = UnicodeWriter(saveFile)
                        k = []

                        for i in range(len(l)):
                            if isinstance(l[i], basestring):
                                if isinstance(l[i],unicode):
                                    l[i] = l[i].encode("utf-8")
                                    l[i] = removeSpecialKey(l[i])
        #                            print i
        #                            print type(l[i])
        #                            print l[i]
                            k = k  + [l[i]]            
                        wb.writerow(k)
                        wpb.writerow(k)
                        saveFile.close()
                        savePreviousFile.close()
                except IndexError:
                    print IndexError
                    break
            print "Getting %d to %d ..." %(m*20,(m+1)*20)
예제 #4
0
# Dealing with user's parameter
appname = sys.argv[1]
if (len(sys.argv) == 3):
    maxNumReviews = int(sys.argv[2])
    # if specified value is >500, set it to 500 (maximum value).
    if maxNumReviews > 500:
        maxNumReviews = 500
# if not specified, set the number of reviews to 500 (default value).
else:
    maxNumReviews = 500


# ignore unverified HTTPS request warning.
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# authentication
api = GooglePlayAPI(ANDROID_ID)
api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)

# Each request returns 20 reviews.
# Loop until you find no more or reach the limit of 500
for offsetNum in range(0, maxNumReviews, 20):
    reviewResponse = api.reviews(appname, offset=offsetNum)
    print text_format.MessageToString(reviewResponse.getResponse)
    # if nextPageUrl is not present in response, there are no reviews left 
    if not reviewResponse.nextPageUrl:
        break