1

AppHub 是否能让我们同时查看所有市场对我们应用程序的评论?因为我没有找到,所以花了一些时间编写一些代码将它们全部打印在一个文件中,所以我不会浪费时间在每种语言中寻找它们。

我将不胜感激任何更好的解决方案。在最坏的情况下,我很高兴与任何发现它有用的人分享代码。

它使用BeautifulSoup。唯一的参数是应用程序的 id,如下所示:

wp7reviews.py 62289160-6970-4674-85a0-aef3dbe3f93d

这是代码

import sys
import getopt
from urllib2 import URLError
from urllib2 import HTTPError
import urllib2
from BeautifulSoup import BeautifulStoneSoup

opts, extraparams = getopt.getopt(sys.argv[1:], '') 
# starts at the second element of argv since the first one is the script name
# extraparms are extra arguments passed after all option/keywords are assigned
# opts is a list containing the pair "option"/"value"
#print 'Opts:',opts
#print 'Extra parameters:',extraparams

try:
    appid = extraparams[0]
except:
    #Awsome Linkit appid as default appid
    appid="62289160-6970-4674-85a0-aef3dbe3f93d"

allreviewsFILE = open("allreviews.txt", "w")

def output(text):
    allreviewsFILE.write(text)
    #print text,

def outputln(text):
    allreviewsFILE.write(text+'\n')
    #print text


def geturl(lang):
    return "http://catalog.zune.net/v3.2/"+lang+"/apps/"+appid
try:

    request = urllib2.Request(geturl("en-us")) 
    fd = urllib2.urlopen(request)
    content = fd.read()
    fd.close()

    soup = BeautifulStoneSoup(content)

    try:
        outputln("App title: "+soup.findAll("a:title")[0].string)
        outputln("");
    except:
        print "Failed to get App Title"

    langs = ["en-us", "en-gb", "de-de",
             "fr-fr", "es-es", "it-it",
             "en-au", "de-at", "fr-be",
             "fr-ca", "en-ca", "en-hk",
             "en-in", "en-ie", "es-mx",
             "en-nz", "en-sg", "de-ch",
             "fr-ch", "zh-hk", "zh-cn",
             "en-hk"]

    outputln("Here we got reviews from each marketplace")
    for lang in langs:
        request = urllib2.Request(geturl(lang)+"/reviews")    
        fd = urllib2.urlopen(request)

        print "Fetching "+lang+"...",
        content = fd.read()
        fd.close()
        print "OK"

        soup = BeautifulStoneSoup(content)
        #print soup.prettify()

        contents = soup.findAll("a:content")
        ratings = soup.findAll("userrating")

        l = len(contents)
        if l > 0:
            outputln("-----------   "+lang+"   ---------------------------------------------------")
            outputln("")
        for i in range(0, l):
            output(ratings[i].string+"/10 - ")
            if len(contents[i].contents) > 0:
                try:
                    outputln(contents[i].contents[0])
                except:
                    outputln("*** Unknown chars ***")
            else:
                outputln("Rating only")
            outputln("")

except HTTPError, e:
    print("Error during request!\n")
    print("Cod.: ", e.code)

except URLError, e:
    print("Invalid URL!\n")
    print("Message: ", e.reason)
4

2 回答 2

1

还有一个名为AppTracker的免费 WP7 应用程序,它允许您跟踪来自不同地区的评论,并将它们翻译成您的母语

于 2012-05-05T19:29:56.040 回答
1

已经有一个网站可以为您提供此信息。看看http://wp7reviews.tomverhoeff.com/

于 2012-05-05T17:35:21.593 回答