Created
June 9, 2015 23:02
-
-
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
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>) |
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
@dvlmcr69 you should change the country field.
such as us, ko, ru, ca