美文网首页大数据 爬虫Python AI Sql
App Store把app的评论扒下来

App Store把app的评论扒下来

作者: freesan44 | 来源:发表于2019-01-03 11:51 被阅读48次

    前言

    公司有需求把评论进行统计分析,就把App Store的评论扒下来并记录

    搜索记录

    searchIOSReview

    def searchIOSReview(appId,pageNo):
        url = "https://itunes.apple.com/cn/rss/customerreviews/page="+pageNo+"/id="+appId+"/sortby=mostrecent/json"
        httpManager = urllib3.PoolManager()
        urllib3.disable_warnings()
        req = httpManager.request('GET', url)
        # print(req.data)
        jsonData = json.loads(req.data)
        # print(jsonData)
        array = jsonData['feed']['entry']
        reviewList = []
        for each in array:
            dic = each['author']
            name = dic['name']['label']
            uri = dic['uri']['label']
            version = each['im:version']['label']
            rating = each['im:rating']['label']
            idStr = each['id']['label']
            title = each['title']['label']
            content = each['content']['label']
            i = [uri,name,version,rating,idStr,title,content]
            reviewList.append(i)
        print('第'+pageNo+'页')
        return reviewList
    

    生产文件

    def saveProductData(fileName,SheetName,productList):
        #创建列表
        headRowList = ['uri','name','version','rating','id','title','content']
        ExcelFileManager.creatExcelFile(fileName,SheetName,headRowList)
        print("创建文件成功")
        #保存数据
        ExcelFileManager.addDataToExcelFile(fileName,SheetName,productList)
        print("保存数据成功")
    

    运行

    if __name__ == '__main__':
        allPList = []
        for i in range(0,pages):
            plist = searchIOSReview(appId,str(i+1))
            allPList += plist
    
        fileName = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
        saveProductData(fileName,'iOS',allPList)
    

    结果

    链接:https://github.com/freesan44/AppReviews

    相关文章

      网友评论

        本文标题:App Store把app的评论扒下来

        本文链接:https://www.haomeiwen.com/subject/delfrqtx.html