【问题标题】:Getting all reviews from a specific Windows Phone Marketplace Game从特定的 Windows Phone Marketplace 游戏中获取所有评论
【发布时间】:2012-05-14 19:43:21
【问题描述】:

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)

【问题讨论】:

    标签: windows-phone-7 web-crawler bots marketplace app-hub


    【解决方案1】:

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

    【讨论】:

    • 非常感谢 Vitalij。这正是我想要的。
    • 不客气。 AppTracker+ 也正在开发中,应该很快就会推出 ;)
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2021-03-20
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多