Beispiel #1
0
    def test_non_detailed_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        apps = s.collection("TOP_PAID", "LIFESTYLE", results=5)

        self.assertEqual(5, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #2
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        apps = s.developer("Google LLC", results=5)

        self.assertEqual(5, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #3
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        apps = s.search("dog")

        self.assertEqual(50, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #4
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.search('dog')

        self.assertEqual(20, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #5
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        apps = s.similar("com.android.chrome")

        self.assertGreater(len(apps), 0)
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #6
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.developer('Google LLC', results=5)

        self.assertEqual(5, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #7
0
    def test_non_detailed_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.collection('TOP_PAID', 'LIFESTYLE', results=5)

        self.assertEqual(5, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #8
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.search('dog')

        self.assertEqual(20, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #9
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.collection('TOP_PAID', 'LIFESTYLE', results=5)

        self.assertEqual(5, len(apps))
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #10
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        apps = s.similar('com.android.chrome')

        self.assertGreater(len(apps), 0)
        self.assertTrue(all(key in apps[0] for key in BASIC_KEYS))
        self.assertEqual(len(BASIC_KEYS), len(apps[0].keys()))
Beispiel #11
0
    def test_fetching_app_in_spanish(self):
        s = PlayScraper(hl='es', gl='es')
        app_data = s.details('com.android.chrome')
        self.assertTrue(all(key in app_data for key in DETAIL_KEYS))
        self.assertEqual(len(DETAIL_KEYS), len(app_data.keys()))
        self.assertEqual('com.android.chrome', app_data['app_id'])
        self.assertEqual(['COMMUNICATION'], app_data['category'])

        # additional details are all None because we currently hardcode an
        # English mapping for the various additional info section titles.
        self.assertTrue(all([app_data[x] is None
                            for x in ADDITIONAL_INFO_KEYS]))
Beispiel #12
0
    def test_detailed_collection_different_language(self):
        s = PlayScraper(hl="da", gl="dk")
        apps = s.collection("TOP_FREE", results=1, detailed=True)

        self.assertEqual(1, len(apps))
        self.assertTrue(all(key in apps[0] for key in DETAIL_KEYS))
        self.assertEqual(len(DETAIL_KEYS), len(apps[0].keys()))

        # additional details, like installs, are all None because we currently
        # hardcode an English mapping for the various additional info section
        # titles.
        self.assertTrue(all([apps[0][x] is None
                             for x in ADDITIONAL_INFO_KEYS]))
Beispiel #13
0
    def test_detailed_collection_different_language(self):
        apps_default = self.s.collection('TOP_FREE', results=1, detailed=True)

        s = PlayScraper(hl='da', gl='dk')
        apps = s.collection('TOP_FREE', results=1, detailed=True)

        self.assertEqual(1, len(apps))
        self.assertTrue(all(key in apps[0] for key in DETAIL_KEYS))
        self.assertEqual(len(DETAIL_KEYS), len(apps[0].keys()))

        # additional details, like installs, are all None because we currently
        # hardcode an English mapping for the various additional info section
        # titles.
        self.assertTrue(all([apps[0][x] is None
                            for x in ADDITIONAL_INFO_KEYS]))
Beispiel #14
0
    def test_fetching_app_in_spanish(self):
        s = PlayScraper(hl='es', gl='es')
        app_data = s.details('com.android.chrome')
        self.assertTrue(all(key in app_data for key in DETAIL_KEYS))
        self.assertEqual(len(DETAIL_KEYS), len(app_data.keys()))
        self.assertEqual('com.android.chrome', app_data['app_id'])
        self.assertEqual(['COMMUNICATION'], app_data['category'])
        self.assertTrue(all(x is not None and x.startswith('https://')
                            for x in app_data['screenshots']))

        # additional details, like installs, are all None because we currently
        # hardcode an English mapping for the various additional info section
        # titles.
        self.assertTrue(all([app_data[x] is None
                            for x in ADDITIONAL_INFO_KEYS]))
Beispiel #15
0
 def test_init_with_language_and_geolocation(self):
     s = PlayScraper(hl='ko', gl='kr')
     self.assertEqual('ko', s.language)
     self.assertEqual('kr', s.geolocation)
     self.assertDictEqual({'hl': 'ko',
                           'gl': 'kr'},
                          s.params)
Beispiel #16
0
    def test_fetching_app_in_spanish(self):
        s = PlayScraper(hl="es", gl="es")
        app_data = s.details("com.android.chrome")
        self.assertTrue(all(key in app_data for key in DETAIL_KEYS))
        self.assertEqual(len(DETAIL_KEYS), len(app_data.keys()))
        self.assertEqual("com.android.chrome", app_data["app_id"])
        self.assertEqual(["COMMUNICATION"], app_data["category"])
        self.assertTrue(app_data["screenshots"]
                        and all(x is not None and x.startswith("https://")
                                for x in app_data["screenshots"]))

        # additional details, like installs, are all None because we currently
        # hardcode an English mapping for the various additional info section
        # titles.
        self.assertTrue(
            all([app_data[x] is None for x in ADDITIONAL_INFO_KEYS]))
Beispiel #17
0
 def test_init_with_defaults(self):
     s = PlayScraper()
     self.assertEqual(settings.BASE_URL, s._base_url)
     self.assertEqual(settings.SUGGESTION_URL, s._suggestion_url)
     self.assertEqual(settings.SEARCH_URL, s._search_url)
     self.assertEqual(settings.PAGE_TOKENS, s._pagtok)
     self.assertEqual("en", s.language)
     self.assertEqual("us", s.geolocation)
     self.assertDictEqual({"hl": "en", "gl": "us"}, s.params)
 def test_init_with_defaults(self):
     s = PlayScraper()
     self.assertEqual(settings.BASE_URL, s._base_url)
     self.assertEqual(settings.SUGGESTION_URL, s._suggestion_url)
     self.assertEqual(settings.SEARCH_URL, s._search_url)
     self.assertEqual(settings.PAGE_TOKENS, s._pagtok)
     self.assertEqual('en', s.language)
     self.assertEqual('us', s.geolocation)
     self.assertDictEqual({'hl': 'en', 'gl': 'us'}, s.params)
Beispiel #19
0
 def setUp(self):
     self.s = PlayScraper()
Beispiel #20
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        suggestions = s.suggestions('dog')

        self.assertGreater(len(suggestions), 0)
Beispiel #21
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        categories = s.categories()

        self.assertTrue(all(key in categories for key in CATEGORIES))
Beispiel #22
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        suggestions = s.suggestions('dog')

        self.assertGreater(len(suggestions), 0)
Beispiel #23
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl="da", gl="dk")
        suggestions = s.suggestions("dog")

        self.assertGreater(len(suggestions), 0)
Beispiel #24
0
 def test_init_with_language_and_geolocation(self):
     s = PlayScraper(hl="ko", gl="kr")
     self.assertEqual("ko", s.language)
     self.assertEqual("kr", s.geolocation)
     self.assertDictEqual({"hl": "ko", "gl": "kr"}, s.params)
Beispiel #25
0
import concurrent
import json
import os
from concurrent.futures.thread import ThreadPoolExecutor
from datetime import datetime
from threading import Lock

import play_scraper
import play_scraper.settings
import play_scraper.utils
from play_scraper.scraper import PlayScraper

scraper = PlayScraper()
play_scraper.settings.CONCURRENT_REQUESTS = 20
base_addr = "data"

stats_lock = Lock()
stats = {
    'details-checked': set(),
    'developers-not-checked': set(),
    'developers-checked': set(),
    'similars-checked': set(),
    'similars-not-checked': set(),
    'categories-checked': set(),
}


def load_stats():
    log('loading stats....')
    for file in stats:
        addr = os.path.join(base_addr, f'stats/{file}.txt')
Beispiel #26
0
 def test_invalid_geolocation_code_raises(self):
     with self.assertRaises(ValueError) as e:
         PlayScraper(gl="invalid")
     self.assertEqual("invalid is not a valid geolocation country code.",
                      str(e.exception))
Beispiel #27
0
 def test_invalid_language_code_raises(self):
     with self.assertRaises(ValueError) as e:
         PlayScraper(hl="invalid")
     self.assertEqual("invalid is not a valid language interface code.",
                      str(e.exception))
Beispiel #28
0
    def test_different_language_and_country(self):
        s = PlayScraper(hl='da', gl='dk')
        categories = s.categories()

        self.assertTrue(all(key in categories for key in CATEGORIES))