def test_request_once(self):
        with patch("google_play_scraper.features.reviews.reviews",
                   wraps=reviews) as mock_reviews:
            result = reviews_all("co.kr.uaram.userdeliver_")
            self.assertEqual(1, mock_reviews.call_count)

        result_of_reviews, _ = reviews("co.kr.uaram.userdeliver_", count=10000)

        self.assertTrue(0 < len(result) < 10)
        self.assertEqual(len(result), len(result_of_reviews))
Exemplo n.º 2
0
    def test_request_multiple_times(self):
        with patch(
            "google_play_scraper.features.reviews.reviews", wraps=reviews
        ) as mock_reviews:
            result = reviews_all("co.kr.uaram.userdeliver_", lang="ko", country="kr")
            self.assertEqual(2, mock_reviews.call_count)

        result_of_reviews, _ = reviews(
            "co.kr.uaram.userdeliver_", lang="ko", country="kr", count=10000
        )

        self.assertTrue(300 < len(result) < 500)
        self.assertEqual(len(result), len(result_of_reviews))
Exemplo n.º 3
0
    def test_no_reviews(self):
        result = reviews_all("product.dp.io.ab180blog",
                             lang="sw",
                             country="it")

        self.assertListEqual([], result)
    def test_no_reviews(self):
        result = reviews_all("com.spotify.music", lang="sw", country="it")

        self.assertListEqual([], result)
#-----------------------------------------------------------------------------------------------

get_ipython().system('pip install google_play_scraper')
get_ipython().system('pip install sklearn')

import pandas as pd
from google_play_scraper.features.reviews import Sort, reviews_all, reviews
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation

#-----------------------------------------------------------------------------------------------
# Reviews data extraction
#-----------------------------------------------------------------------------------------------

result = reviews_all('com.bt.bms',
                     sleep_milliseconds=0,
                     lang='en',
                     country='us')

#-----------------------------------------------------------------------------------------------
# Create dataframe of the reviews
#-----------------------------------------------------------------------------------------------

df = pd.DataFrame(result)

print(f'Total textual reviews: {len(result)} \n')

unique_users = len(df['userName'].unique())
unknown_users = len(df[df['userName'] == 'A Google user'])
total_reviews = len(df)

print(f'Total unique users : {unique_users}')