Skip to content

Instantly share code, notes, and snippets.

@kgn
Created June 9, 2015 23:02
Show Gist options
  • Save kgn/e96e7ae71a38447ac614 to your computer and use it in GitHub Desktop.
Save kgn/e96e7ae71a38447ac614 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
#!/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>)
@sapna88
Copy link

sapna88 commented Sep 13, 2021

Can someone help, Its not going beyond 500 reviews.How to get all the reviews

@kgn
Copy link
Author

kgn commented Sep 25, 2021

500 is the max Apple stores, you'll need to pull them periodically over time if you want to build up your own dataset of reviews

@dvlmcr69
Copy link

Hi I'm getting this output:
STARTED 1
STARTED 2
STARTED 3
STARTED 4
STARTED 5
STARTED 6
STARTED 7
STARTED 8
STARTED 9
STARTED 10
STARTED 11
1
[{}]

What's wrong? can someone help?

@RavenKyu
Copy link

@dvlmcr69 you should change the country field.

 url = (f'https://itunes.apple.com/------> ru <-------/rss/customerreviews/page={page}/id={app_id}/sortBy=mostRecent/json')

such as us, ko, ru, ca

@ClebsonLu
Copy link

Does this script have the same purpose as the app_store_scraper library?
I see that the return comes different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment