-
-
Save amjad-desai/bd0892592ad60d2881ffdcb0ade8c85c to your computer and use it in GitHub Desktop.
App Reviews - Python script to retrieve App Store reviews and save them to a CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
try: | |
# For Python 3.0 and later | |
from urllib.request import urlopen | |
except ImportError: | |
# Fall back to Python 2's urllib2 | |
from urllib2 import urlopen | |
import json | |
import time | |
def getJson(url): | |
response = urlopen(url) | |
data = str(response.read()) | |
return json.loads(data) | |
def getReviews(appID, page=1): | |
url = 'https://itunes.apple.com/rss/customerreviews/id=%s/page=%d/sortby=mostrecent/json' % (appID, page) | |
data = getJson(url).get('feed') | |
if data.get('entry') == None: | |
getReviews(appID, page+1) | |
return | |
for entry in data.get('entry'): | |
if entry.get('im:name'): continue | |
review_id = entry.get('id').get('label') | |
title = entry.get('title').get('label') | |
author = entry.get('author').get('name').get('label') | |
author_url = entry.get('author').get('uri').get('label') | |
version = entry.get('im:version').get('label') | |
rating = entry.get('im:rating').get('label') | |
review = entry.get('content').get('label') | |
vote_count = entry.get('im:voteCount').get('label') | |
csvData = [review_id, title.replace('"', '""'), author, author_url, version, rating, review.replace('"', '""'), vote_count] | |
print '"'+'","'.join(csvData)+'"' | |
getReviews(appID, page+1) | |
csvTitles = ['review_id', 'title', 'author', 'author_url', 'version', 'rating', 'review', 'vote_count'] | |
print ','.join(csvTitles) | |
getReviews(<app store id>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment