google-play-scraper icon indicating copy to clipboard operation
google-play-scraper copied to clipboard

Scrap discounted games and games with pre-registration

Open jbigman opened this issue 2 years ago • 0 comments

Description:

I need to scrap play store to retrieve discounted games and games with pre-registration

3 solutions

  • improve this library with games.js
  • export utils methods in index.d.ts to allow play store scrapping from external code with custom urls
  • do nothing ^^

Improve this library with game search methods

Urls we can use:

const topsellingGames = 'https://play.google.com/store/apps/collection/topselling_free?clp=ChcKFQoPdG9wc2VsbGluZ19mcmVlEAcYAw%3D%3D:S:ANO1ljLwMrI&gsr=ChkKFwoVCg90b3BzZWxsaW5nX2ZyZWUQBxgD:S:ANO1ljIxP20';
const popularGames = '/store/apps/collection/promotion_30009c9_row_popular_games?clp=CisKKQojcHJvbW90aW9uXzMwMDA5Yzlfcm93X3BvcHVsYXJfZ2FtZXMQShgD:S:ANO1ljJKGaU&gsr=Ci0KKwopCiNwcm9tb3Rpb25fMzAwMDljOV9yb3dfcG9wdWxhcl9nYW1lcxBKGAM%3D:S:ANO1ljIJdN4';
const freeGames = '/store/apps/collection/promotion_300201f_top_selling_free_games?clp=CjAKLgoocHJvbW90aW9uXzMwMDIwMWZfdG9wX3NlbGxpbmdfZnJlZV9nYW1lcxBKGAM%3D:S:ANO1ljJaWqI&gsr=CjIKMAouCihwcm9tb3Rpb25fMzAwMjAxZl90b3Bfc2VsbGluZ19mcmVlX2dhbWVzEEoYAw%3D%3D:S:ANO1ljJERt0';
const discountGames = '/store/apps/collection/promotion_3002c9b_gamesDynamic_cyberweek2017?clp=CjQKMgoscHJvbW90aW9uXzMwMDJjOWJfZ2FtZXNEeW5hbWljX2N5YmVyd2VlazIwMTcQShgD:S:ANO1ljI2ADA&gsr=CjYKNAoyCixwcm9tb3Rpb25fMzAwMmM5Yl9nYW1lc0R5bmFtaWNfY3liZXJ3ZWVrMjAxNxBKGAM%3D:S:ANO1ljK6Aoo';
const preRegistrationGames = '/store/apps/collection/promotion_3000000d51_pre_registration_games';

Implementation

Exemple available in my game-improv branch : https://github.com/jbigman/google-play-scraper/blob/game-improv/lib/games.js (Almost a duplicate of search.js. Some refactoring would be great because most files share the same structure/pattern)

interface IOptions {
    requestOptions?: any,
    lang?: string,
    country?: string,
    throttle?: any,
    filter?: 'FREE' | 'NEW' | 'PREREGISTER' | "DISCOUNT" | 'POPULAR' | 'TOPSELLINGS',
    fullDetail?: boolean,
    num?: number,
    cache?: any
}
const games = async (opts: IOptions): Promise<IAppItemFullDetail[]> => {}

Add utils method to the index.d.ts file

// constants
export const BASE_URL = 'https://play.google.com';

// Utils
export const request: (opts, limit) => Promise<any>
export const scriptData: {
  parse: (response) => any,
  parseServiceRequests: (response) => any,
  extractor: (mappings) => any,
  extractDataWithServiceRequestId: (parsedData, spec) => any
}
export const processFullDetailApps: (apps, opts) => Promise<IAppItemFullDetail[]>
export const checkFinished: (opts, savedApps, nextToken) => any

Do nothing

Document in readme how Typescript users have to extend module interface if they need it

import "google-play-scraper"; // Trigger declaration merging

declare module "google-play-scraper" {
    // constants
    export const BASE_URL = 'https://play.google.com';

    // Utils
    export const request: (opts, limit) => Promise<any>;
    export const scriptData: {
        parse: (response) => any,
        parseServiceRequests: (response) => any,
        extractor: (mappings) => any,
        extractDataWithServiceRequestId: (parsedData, spec) => any
    };
    export const processFullDetailApps: (apps, opts) => Promise<IAppItemFullDetail[]>;
    export const checkFinished: (opts, savedApps, nextToken) => any;
}

What's the best thing to do ?

jbigman avatar Aug 07 '23 00:08 jbigman