Scrape Google Play Search Apps in Python
Tags: python, tutotrial, webscraping, programming
Published: 2022-04-08 14:49:20

- <a href="#what_will_be_scraped">What will be scraped</a>
- <a href="#fullcode">Full Code</a>
- <a href="#preparation">Preparation</a>
- <a href="#code_explanation">Code Explanation</a>
    - <a href="#top_level_code_environment">Top-level code environment</a>
    - <a href="#scroll_page">Scroll page</a>
    - <a href="#scrape_top_charts">Scrape top charts</a>
    - <a href="#scrape_all_sections">Scrape all sections</a>
- <a href="#google_play_apps">Using Google Play Apps Store API from SerpApi</a>
- <a href="#links">Links</a>


<h2 id="what_will_be_scraped">What will be scraped</h2>

![wwbs-google-play-apps](https://user-images.githubusercontent.com/81998012/193964007-c1513bab-7f70-4bfe-9fec-343a1f323f27.png)

📌Note: Google Play gives different results for logged in and not logged in users.


<h2 id="fullcode">Full Code</h2>

If you don't need explanation, have a look at [full code example in the online IDE](https://replit.com/@chukhraiartur/blog-google-play-apps#main.py).

```python
import time, json
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from parsel import Selector

google_play_apps = {
    'Top charts': {
        'Top free': [],
        'Top grossing': [],
        'Top paid': []
    },
}


def scroll_page(url):
    service = Service(ChromeDriverManager().install())

    options = webdriver.ChromeOptions()
    options.add_argument("--headless")
    options.add_argument("--lang=en")
    options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36")
    options.add_argument("--no-sandbox")

    driver = webdriver.Chrome(service=service, options=options)
    driver.get(url)

    while True:
        try:
            driver.execute_script("document.querySelector('.snByac').click();")
            WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))
            break
        except:
            driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
            WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))

    scrape_top_charts(driver=driver, chart='Top free', button_selector='#ct\|apps_topselling_free .ypTNYd')
    scrape_top_charts(driver=driver, chart='Top grossing', button_selector='#ct\|apps_topgrossing .ypTNYd')
    scrape_top_charts(driver=driver, chart='Top paid', button_selector='#ct\|apps_topselling_paid .ypTNYd')
    
    selector = Selector(driver.page_source)
    driver.quit()

    return selector
	

def scrape_top_charts(driver, chart, button_selector):
    button = driver.find_element(By.CSS_SELECTOR, button_selector)
    driver.execute_script("arguments[0].click();", button)
    time.sleep(2)
    selector = Selector(driver.page_source)

    for result in selector.css('.itIJzb'):
        title = result.css('.OnEJge::text').get()
        link = 'https://play.google.com' + result.css('::attr(href)').get()
        category = result.css('.ubGTjb .sT93pb.w2kbF:not(.K4Wkre)::text').get()
        rating = float(result.css('.CKzsaf .w2kbF::text').get())
        thumbnail = result.css('.stzEZd::attr(srcset)').get().replace(' 2x', '')

        google_play_apps['Top charts'][chart].append({
            'title': title,
            'link': link,
            'category': category,
            'rating': rating,
            'thumbnail': thumbnail,
        })


def scrape_all_sections(selector):	
    for section in selector.css('section'):
        section_title = section.css('.kcen6d span::text').get()
        google_play_apps[section_title] = []

        for app in section.css('.UVEnyf'):
            title = app.css('.Epkrse::text').get()
            link = 'https://play.google.com' + app.css('.Si6A0c::attr(href)').get()
            rating = app.css('.LrNMN::text').get()
            rating = float(rating) if rating else rating
            thumbnail = app.css('.Q8CSx::attr(srcset)').get().replace(' 2x', '')

            google_play_apps[section_title].append({
                'title': title,
                'link': link,
                'rating': rating,
                'thumbnail': thumbnail,
            })
    
    print(json.dumps(google_play_apps, indent=2, ensure_ascii=False))
	

def scrape_google_play_apps():
    params = {
        'device': 'phone',  
        'hl': 'en_GB',		# language 
        'gl': 'US',			# country of the search
    }

    URL = f"https://play.google.com/store/apps?device={params['device']}&hl={params['hl']}&gl={params['gl']}"

    result = scroll_page(URL)
    scrape_all_sections(result)


if __name__ == "__main__":
    scrape_google_play_apps()
```


<h2 id="preparation">Preparation</h2>

**Install libraries**:

```lang-none
pip install parsel selenium webdriver webdriver_manager
```

**Reduce the chance of being blocked**

Make sure you're using [request headers](https://docs.python-requests.org/en/master/user/quickstart/#custom-headers) [`user-agent`](https://developer.mozilla.org/en-US/docs/Glossary/User_agent) to act as a "real" user visit. Because default `requests` `user-agent` is [`python-requests`](https://github.com/psf/requests/blob/589c4547338b592b1fb77c65663d8aa6fbb7e38b/requests/utils.py#L808-L814) and websites understand that it's most likely a script that sends a request. [Check what's your `user-agent`](https://www.whatismybrowser.com/detect/what-is-my-user-agent/).

There's a [how to reduce the chance of being blocked while web scraping blog post](https://serpapi.com/blog/how-to-reduce-chance-of-being-blocked-while-web/) that can get you familiar with basic and more advanced approaches.


<h2 id="code_explanation">Code Explanation</h2>

Import libraries:

```python
import time, json
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from parsel import Selector
```

| Library       | Purpose                                                            |
|---------------|--------------------------------------------------------------------|
| [`time`](https://docs.python.org/3/library/time.html)    | to work with time in Python.                                  |
| [`json`](https://docs.python.org/3/library/json.html)        | to convert extracted data to a JSON object.                        |
| [`webdriver`](https://www.selenium.dev/documentation/webdriver/)    | to drive a browser natively, as a user would, either locally or on a remote machine using the Selenium server.                                  |
| [`Service`](https://www.selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.service.html)    | to manage the starting and stopping of the ChromeDriver.                                  |
| [`By`](https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.by.html)    | to set of supported locator strategies (By.ID, By.TAG_NAME, By.XPATH etc).                                  |
| [`WebDriverWait`](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.wait.html#selenium.webdriver.support.wait.WebDriverWait)    | to wait only as long as required..                                  |
| [`expected_conditions`](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.wait.html#selenium.webdriver.support.wait.WebDriverWait)    | contains a set of predefined conditions to use with WebDriverWait.                                  |
| [`Selector`](https://parsel.readthedocs.io/en/latest/)      | XML/HTML parser that have full [XPath](https://en.wikipedia.org/wiki/XPath) and CSS selectors support. |

Define dictionary structure:

```python
google_play_apps = {
    'Top charts': {
        'Top free': [],
        'Top grossing': [],
        'Top paid': []
    },
}
```


<h3 id="top_level_code_environment">Top-level code environment</h3>

At the beginning of the function, parameters are defined for generating the `URL`. If you want to pass other parameters to the URL, you can do so using the `params` dictionary. The parameters affect the output results:

```python
params = {
    'device': 'phone',  
    'hl': 'en_GB',		# language 
    'gl': 'US',			# country of the search
}
```

Next, the URL is passed to the `scroll_page(URL)` function to scroll the page and get all data. The result that this function returns is passed to the `scrape_all_categories(result)` function to extract the necessary data. The explanation of these functions will be in the corresponding headings below.

This code uses the generally accepted rule of using the [`__name__ == "__main__"`](https://docs.python.org/3/library/__main__.html#) construct: 

```python
def scrape_google_play_apps():
    params = {
        'device': 'phone',  
        'hl': 'en_GB',		# language 
        'gl': 'US',			# country of the search
    }

    URL = f"https://play.google.com/store/apps?device={params['device']}&hl={params['hl']}&gl={params['gl']}"

    result = scroll_page(URL)
    scrape_all_sections(result)


if __name__ == "__main__":
    scrape_google_play_apps()
```

This check will only be performed if the user has run this file. If the user imports this file into another, then the check will not work.

You can watch the video [Python Tutorial: if __name__ == '__main__'](https://www.youtube.com/watch?v=sugvnHA7ElY&t=1s) for more details.


<h3 id="scroll_page">Scroll page</h3>

The function takes the URL and returns a full HTML structure.

First, let's understand how pagination works on the Google Play Apps page. Data does not load immediately. If the user needs more data, they will simply scroll the page and site download a small package of data. 

Accordingly, to get all the data, you need to scroll to the end of the page. But we will face the problem that on the last scroll the _SHOW MORE_ button appears. By clicking on it, you will get the last piece of data. A page scroll demo is shown below:

![google-play-apps-scroll](https://user-images.githubusercontent.com/81998012/193962130-71d98258-7bcf-4018-bec1-0ead46ad6e2d.gif)

In this case, [`selenium` library](https://www.selenium.dev/documentation/webdriver/) is used, which allows you to simulate user actions in the browser. For `selenium` to work, you need to use [`ChromeDriver`](https://chromedriver.chromium.org/downloads), which can be downloaded manually or using code. In our case, the second method is used. To control the start and stop of `ChromeDriver`, you need to use [`Service`](https://www.selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.service.html) which will install browser binaries under the hood:

```python
service = Service(ChromeDriverManager().install())
```

You should also add `options` to work correctly:

```python
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--lang=en')
options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36')
options.add_argument('--no-sandbox')
```

| Chrome options                                                                     | Explanation                                           |
|------------------------------------------------------------------------------|---------------------------------------------------|
| `--headless` | to run Chrome in headless mode. |
| `--lang=en` | to set the browser language to English. |
| `user-agent` | to act as a "real" user request from the browser by passing it to [request headers](https://docs.python-requests.org/en/master/user/quickstart/#custom-headers). [Check what's your `user-agent`](https://www.whatismybrowser.com/detect/what-is-my-user-agent). |
| `--no-sandbox` | to make chromedriver work properly on different machines. |

Now we can start [`webdriver`](https://www.selenium.dev/documentation/webdriver/) and pass the url to the [`get()` method](https://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webdriver.WebDriver.get).

```python
driver = webdriver.Chrome(service=service, options=options)
driver.get(url)
```

How does the page scrolling algorithm work? In each iteration of the loop, the program looks for the button selector. If the button is present, then the program is clicking on it and the data is loaded, after which the loop ends. Otherwise, the page scrolls down and the data loads.

Scrolling a page and clicking on a button is done by pasting the JavaScript code into the [`execute_script()`](https://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webdriver.WebDriver.execute_script) method.

```python
while True:
    try:
        driver.execute_script("document.querySelector('.snByac').click();")
        WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))
        break
    except:
        driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))
```

Sometimes it is difficult to calculate how long it will take to load a page, it all depends on the speed of the Internet, the power of the computer and other factors. The method described below is much better than using a delay in seconds since the wait occurs exactly until the moment when the page is fully loaded:

```python
WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))
```

📌Note: In this case, we give 10 seconds for the page to load, if it loads earlier then the wait will end.

After all the data has been loaded, you need to pass them to the `scrape_top_charts` function. This function will be described in the relevant section below. It is important to extract the data before we stop the driver.

```python
scrape_top_charts(driver=driver, chart='Top free', button_selector='#ct\|apps_topselling_free .ypTNYd')
scrape_top_charts(driver=driver, chart='Top grossing', button_selector='#ct\|apps_topgrossing .ypTNYd')
scrape_top_charts(driver=driver, chart='Top paid', button_selector='#ct\|apps_topselling_paid .ypTNYd')
```

Now we need to process HTML using from [`Parsel`](https://parsel.readthedocs.io/en/latest/) package, in which we pass the `HTML` structure with all the data that was received after scrolling the page. This is necessary to successfully retrieve data in the next function. After all the operations are done, stop the driver:

```python
selector = Selector(driver.page_source)
driver.quit()
```

The function looks like this:

```python
def scroll_page(url):
    service = Service(ChromeDriverManager().install())

    options = webdriver.ChromeOptions()
    options.add_argument("--headless")
    options.add_argument("--lang=en")
    options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36")
    options.add_argument("--no-sandbox")

    driver = webdriver.Chrome(service=service, options=options)
    driver.get(url)

    while True:
        try:
            driver.execute_script("document.querySelector('.snByac').click();")
            WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))
            break
        except:
            driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
            WebDriverWait(driver, 10000).until(EC.visibility_of_element_located((By.TAG_NAME, 'body')))

    scrape_top_charts(driver=driver, chart='Top free', button_selector='#ct\|apps_topselling_free .ypTNYd')
    scrape_top_charts(driver=driver, chart='Top grossing', button_selector='#ct\|apps_topgrossing .ypTNYd')
    scrape_top_charts(driver=driver, chart='Top paid', button_selector='#ct\|apps_topselling_paid .ypTNYd')
    
    selector = Selector(driver.page_source)
    driver.quit()

    return selector
```


<h3 id="scrape_top_charts">Scrape top charts</h3>

The function takes 3 parameters:

- `driver` - the full HTML structure.
- `chart` - the chart from which the data will be retrieved.
- `button_selector` - the selector of the button to go to the corresponding chart.

On the GIF, I show how the top charts work:

![google-play-apps-top-charts](https://user-images.githubusercontent.com/81998012/193962636-88136e30-b8bd-4656-89c9-70a7919da2f5.gif)

The corresponding data is loaded by pressing the corresponding buttons. The process of clicking the button and creating the object to retrieve data is the same as we did before in the `scroll_page` function:

```python
button = driver.find_element(By.CSS_SELECTOR, button_selector)
driver.execute_script("arguments[0].click();", button)
time.sleep(2)
selector = Selector(driver.page_source)
```

To extract the necessary data, you need to find the selector where they are located. In our case, this is the `.itIJzb` selector, which contains all applications. You need to iterate each application in the loop:

```python
for result in selector.css('.itIJzb'):
    # data extraction will be here
```

For each app, data such as `title`, `link`, `category`, `rating` and `thumbnail` are extracted. You need to find the matching selector and get the text or attribute value. I want to additionally note that the `thumbnail` is retrieved from the `srcset` attribute, where it is of better quality:

```python
title = result.css('.OnEJge::text').get()
link = 'https://play.google.com' + result.css('::attr(href)').get()
category = result.css('.ubGTjb .sT93pb.w2kbF:not(.K4Wkre)::text').get()
rating = float(result.css('.CKzsaf .w2kbF::text').get())
thumbnail = result.css('.stzEZd::attr(srcset)').get().replace(' 2x', '')
```

After extracting the data, they are added to the `google_play_apps` dictionary by key. The key is the value of the `сhart` argument:

```python
google_play_apps['Top charts'][chart].append({
    'title': title,
    'link': link,
    'category': category,
    'rating': rating,
    'thumbnail': thumbnail,
})
```

The complete function to scrape top charts would look like this:

```python
def scrape_top_charts(driver, chart, button_selector):
    button = driver.find_element(By.CSS_SELECTOR, button_selector)
    driver.execute_script("arguments[0].click();", button)
    time.sleep(2)
    selector = Selector(driver.page_source)

    for result in selector.css('.itIJzb'):
        title = result.css('.OnEJge::text').get()
        link = 'https://play.google.com' + result.css('::attr(href)').get()
        category = result.css('.ubGTjb .sT93pb.w2kbF:not(.K4Wkre)::text').get()
        rating = float(result.css('.CKzsaf .w2kbF::text').get())
        thumbnail = result.css('.stzEZd::attr(srcset)').get().replace(' 2x', '')

        google_play_apps['Top charts'][chart].append({
            'title': title,
            'link': link,
            'category': category,
            'rating': rating,
            'thumbnail': thumbnail,
        })
```

|Code|Explanation|
|----|-----------|
|[`css()`](https://parsel.readthedocs.io/en/latest/usage.html#using-selectors)| to access elements by the passed selector.|
|[`::text` or `::attr(<attribute>)`](https://github.com/scrapy/parsel/blob/90397dcd0b2c1cbb91e44f65c50f9e11628ba028/parsel/csstranslator.py#L48-L51)| to extract textual or attribute data from the node. |
|[`get()`](https://parsel.readthedocs.io/en/latest/usage.html#usage)| to actually extract the textual data.|
|[`float()`](https://docs.python.org/3/library/functions.html#float)| to make a floating number from a string value.|
|[`replace()`](https://docs.python.org/3/library/stdtypes.html#str.replace)| to replace all occurrences of the old substring with the new one without extra elements.|

In the `scroll_page` function, we called this function 3 times to retrieve data from _Top free_, _Top grossing_ and _Top paid_ sections.


<h3 id="scrape_all_sections">Scrape all sections</h3>

This function takes a full HTML structure and prints all results in JSON format.

To retrieve data from all sections, you need to find the `section` selector of the section. You need to iterate each section in the loop:

```python
for section in selector.css('section'):
    # data extraction will be here
```

It is necessary to extract the `section_title` and make it a key in the `google_play_apps` dictionary, where a list of extracted data for each application will be added later:

```python
section_title = section.css('.kcen6d span::text').get()
google_play_apps[section_title] = []
```

Each section has a certain number of applications that should also need to iterate in another loop using the `.UVEnyf` selector:

```python
for app in section.css('.UVEnyf'):
    # data extraction will be here
```

For applications that are in sections, there is no such parameter as `categories`. Data is also retrieved by other selectors. 

Also, there is a slight difference in `rating` extraction. The fact is that for some games the rating is not displayed. In this case, a [ternary expression](https://docs.python.org/3/reference/expressions.html#conditional-expressions) is used, which extracts the numerical values for the data, if any:

```python
title = app.css('.Epkrse::text').get()
link = 'https://play.google.com' + app.css('.Si6A0c::attr(href)').get()
rating = app.css('.LrNMN::text').get()
rating = float(rating) if rating else rating
thumbnail = app.css('.Q8CSx::attr(srcset)').get().replace(' 2x', '')
```

The complete function to scrape all categories would look like this:

```python
def scrape_all_sections(selector):	
    for section in selector.css('section'):
        section_title = section.css('.kcen6d span::text').get()
        google_play_apps[section_title] = []

        for app in section.css('.UVEnyf'):
            title = app.css('.Epkrse::text').get()
            link = 'https://play.google.com' + app.css('.Si6A0c::attr(href)').get()
            rating = app.css('.LrNMN::text').get()
            rating = float(rating) if rating else rating
            thumbnail = app.css('.Q8CSx::attr(srcset)').get().replace(' 2x', '')

            google_play_apps[section_title].append({
                'title': title,
                'link': link,
                'rating': rating,
                'thumbnail': thumbnail,
            })
    
    print(json.dumps(google_play_apps, indent=2, ensure_ascii=False))
```

Output:

```json
{
  "Top charts": {
    "Top free": [
      {
        "title": "Disney+",
        "link": "https://play.google.com/store/apps/details?id=com.disney.disneyplus",
        "category": "Entertainment",
        "rating": 4.5,
        "thumbnail": "https://play-lh.googleusercontent.com/xoGGYH2LgLibLDBoxMg-ZE16b-RNfITw_OgXBWRAPin2FZY4FGB9QKBYApR-0rSCkQ=s128-rw"
      },
      ... other apps
    ],
    "Top grossing": [
      {
        "title": "Google One",
        "link": "https://play.google.com/store/apps/details?id=com.google.android.apps.subscriptions.red",
        "category": "Productivity",
        "rating": 4.3,
        "thumbnail": "https://play-lh.googleusercontent.com/DGAleS46qOedNzJGsB3e29QLpL6Qi6EwIDze95nBvxMAMGEmbE6KOW__2haEkHVDs4Y=s128-rw"
      },
      ... other apps
    ],
    "Top paid": [
      {
        "title": "Muscle Trigger Point Anatomy",
        "link": "https://play.google.com/store/apps/details?id=com.real.bodywork.muscle.trigger.points",
        "category": "Medical",
        "rating": 4.6,
        "thumbnail": "https://play-lh.googleusercontent.com/dX8bDLm4Aq0vF131uvjJO83EghJ9fIPIEfgLdcXwUXF7iZnpxkR53uy94H9FHocJRQ=s128-rw"
      },
      ... other apps
    ]
  },
  "Popular apps": [
    {
      "title": "WhatsApp Messenger",
      "link": "https://play.google.com/store/apps/details?id=com.whatsapp",
      "rating": 4.3,
      "thumbnail": "https://play-lh.googleusercontent.com/bYtqbOcTYOlgc6gqZ2rwb8lptHuwlNE75zYJu6Bn076-hTmvd96HH-6v7S0YUAAJXoJN=s512-rw"
    },
    ... other apps
  ],
  ... other sections
  "Book a getaway": [
    {
      "title": "Hotels.com: Book Hotels & More",
      "link": "https://play.google.com/store/apps/details?id=com.hcom.android",
      "rating": 4.4,
      "thumbnail": "https://play-lh.googleusercontent.com/onuxspmiR0fJZRWXZCToyBPht5yZE55drqWqoWWDj9YwJvKpg2AY4lt1LdymRYkRlh0=s512-rw"
    },
    ... other apps
  ]
}
```

<h2 id="google_play_apps">Using Google Play Apps Store API from SerpApi</h2>

This section is to show the comparison between the DIY solution and our solution.

The main difference is that it's a quicker approach. [Google Play Apps Store API](https://serpapi.com/google-play-apps) will bypass blocks from search engines and you don't have to create the parser from scratch and maintain it.

First, we need to install [`google-search-results`](https://pypi.org/project/google-search-results/):

```lang-none
pip install google-search-results
```

Import the necessary libraries for work:

```python
from serpapi import GoogleSearch
import os, json
```

Next, we write a search query and the necessary parameters for making a request:

```python
params = {
    # https://docs.python.org/3/library/os.html#os.getenv
    'api_key': os.getenv('API_KEY'),    # your serpapi api
    'engine': 'google_play',			# SerpApi search engine
    'store': 'apps'						# Google Play Apps
}
```

We then create a `search` object where the data is retrieved from the SerpApi backend. In the `result_dict` dictionary we get data from JSON:

```python
search = GoogleSearch(params)
result_dict = search.get_dict()
```

The data is retrieved quite simply, we just need to turn to the `'organic_results'` key:

```python
google_play_apps = result_dict['organic_results']
```

Example code to integrate:

```python
from serpapi import GoogleSearch
import os, json

params = {
    # https://docs.python.org/3/library/os.html#os.getenv
    'api_key': os.getenv('API_KEY'),    # your serpapi api
    'engine': 'google_play',			# SerpApi search engine
    'store': 'apps'						# Google Play Apps
}

search = GoogleSearch(params)           # where data extraction happens on the SerpApi backend
result_dict = search.get_dict()         # JSON -> Python dict

google_play_apps = result_dict['organic_results']

print(json.dumps(google_play_apps, indent=2, ensure_ascii=False))
```

Output:

```json
[
  {
    "title": "Popular apps",
    "items": [
      {
        "title": "WhatsApp Messenger",
        "link": "https://play.google.com/store/apps/details?id=com.whatsapp",
        "product_id": "com.whatsapp",
        "serpapi_link": "https://serpapi.com/search.json?engine=google_play_product&gl=us&hl=en&product_id=com.whatsapp&store=apps",
        "rating": 4.3,
        "thumbnail": "https://play-lh.googleusercontent.com/bYtqbOcTYOlgc6gqZ2rwb8lptHuwlNE75zYJu6Bn076-hTmvd96HH-6v7S0YUAAJXoJN=s256"
      },
      ... other items
      {
        "title": "Zoom - One Platform to Connect",
        "link": "https://play.google.com/store/apps/details?id=us.zoom.videomeetings",
        "product_id": "us.zoom.videomeetings",
        "serpapi_link": "https://serpapi.com/search.json?engine=google_play_product&gl=us&hl=en&product_id=us.zoom.videomeetings&store=apps",
        "rating": 4.3,
        "thumbnail": "https://play-lh.googleusercontent.com/yZsmiNjmji3ZoOuLthoVvptLB9cZ0vCmitcky4OUXNcEFV3IEQkrBD2uu5kuWRF5_ERA=s256"
      }
    ]
  },
  ... other sections
  {
    "title": "Communication",
    "items": [
      {
        "title": "Google Voice",
        "link": "https://play.google.com/store/apps/details?id=com.google.android.apps.googlevoice",
        "product_id": "com.google.android.apps.googlevoice",
        "serpapi_link": "https://serpapi.com/search.json?engine=google_play_product&gl=us&hl=en&product_id=com.google.android.apps.googlevoice&store=apps",
        "rating": 4.4,
        "thumbnail": "https://play-lh.googleusercontent.com/Gf8ufuFbtfXO5Y6JuZjnG0iIpZh21zNTqZ5aiAXO8mA38mvXzY-1s27FWbGlp51paQ=s256"
      },
      ... other items
      {
        "title": "Email - Fast & Secure Mail",
        "link": "https://play.google.com/store/apps/details?id=com.easilydo.mail",
        "product_id": "com.easilydo.mail",
        "serpapi_link": "https://serpapi.com/search.json?engine=google_play_product&gl=us&hl=en&product_id=com.easilydo.mail&store=apps",
        "rating": 4.6,
        "thumbnail": "https://play-lh.googleusercontent.com/WvlTOWc59NcVtCfnxMjNZIG2mRHrjMNadTU7dnN2oA3UwT6tz70KodnLOwiimwc49Obx=s256"
      }
    ]
  }
]
```

<h2 id="links">Links</h2>

- [Code in the online IDE](https://replit.com/@chukhraiartur/blog-google-play-apps#main.py)
- [Google Play Apps Store API](https://serpapi.com/google-play-apps)


<p style="text-align: center;">Join us on <a href="https://twitter.com/serp_api">Twitter</a> | <a href="https://www.youtube.com/channel/UCUgIHlYBOD3yA3yDIRhg_mg">YouTube</a></p>

<p style="text-align: center;">Add a  <a href="https://github.com/serpapi/public-roadmap/issues">Feature Request</a>💫 or a <a href="https://github.com/serpapi/public-roadmap/issues">Bug</a>🐞</p>