0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LOL xlsx

Posted at

LOL xlsx

import urllib.request
import json
import xlsxwriter
print("アプリレビューを取得ツールです。")
page=1;
appid=input("アプリIDを入力してください:");
#appid=441668861
workbook = xlsxwriter.Workbook('アプリレビュー.xlsx')
worksheet = workbook.add_worksheet()
format=workbook.add_format()
format.set_border(1)
format.set_border(1)
format_title = workbook.add_format()    
format_title.set_border(1)   
format_title.set_bg_color('#cccccc')
format_title.set_align('left')
format_title.set_bold()    
title=['ユーザー','タイトル','コメント']
worksheet.write_row('A1',title,format_title)
row=1
col=0
count=0

#  
while page<11:
    #https://itunes.apple.com/jp/rss/customerreviews/id=441668861/sortBy=mostRecent/page=4/xml
    myurl="https://itunes.apple.com/rss/customerreviews/page="+str(page)+"/id="+str(appid)+"/json?l=en&&cc=jp"
    response = urllib.request.urlopen(myurl)
    myjson = json.loads(response.read().decode())
    print("データが読み込んでいる......"+str(page*10)+"%")
    if "entry" in myjson["feed"]:
        count+=len(myjson["feed"]["entry"])
        #第一列 ユーザー
        for i in myjson["feed"]["entry"]:
            worksheet.write(row,col,i["author"]["name"]["label"],format)
            row+=1
        #第二列 タイトル  
        row=1+(page-1)*50
        for i in myjson["feed"]["entry"]:
            worksheet.write(row,col+1,i["title"]["label"],format)
            row+=1
        #第三列 コメント
        row=1+(page-1)*50
        for i in myjson["feed"]["entry"]:
            worksheet.write(row,col+2,i["content"]["label"],format)
            row+=1
        page=page+1
        row=(page-1)*50+1
    else:
        print("もうすぐ完了......100%")
        break
if count==0:
    print("データが取得できません、アプリIDをもう一度確認お願い致します。")
else:
    print("xlsxファイルが生成出来ました,トータル"+str(count)+"条。")
workbook.close()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?