Как спарсить play market на python

При парсинге play market столкнулся с такой проблемой. Когда скрипт делал запрос в поисковую систему то он скачивал файл с 40 приложениями на страничке. Это поту что на сайте есть автоподгрузка. Я сразу зашел и посмотрел когда ты прокручиваешь страницу на определеном моменте идет POST запрос и потом возращается json. В нем есть приложения которые подгружаются Я пробую сделать такой же запрос но выдает ошибку Помогите решить задачу. Может есть решение сразу загрузить всю страничку либо как то делать post запрос. Решения надо на Python. Мне не нужно название, картики приложения. Мне самое главное ссылку на страничку приложения, там у меня уже все готово.

import requests
from bs4 import BeautifulSoup

import csv
from random import randint
from os import system
import datetime
from sys import exit

class Search_apps:

    def __init__(self, word, url_search='https://play.google.com/store/search', url='https://play.google.com'):
        self.word = word
        self.url = url
        self.url_search = url_search

    def Search(self):
        search_html = requests.get(self.url_search, params={'q': self.word, 'c': 'apps', 'hl': 'ru'})

        return search_html.text

    def Search_soup(self):
        soup = BeautifulSoup(self.Search(), 'html.parser')

        a_list = []

        div_a = soup.find_all('div', class_='mpg5gc')

        for i in div_a:
            a = i.find('div', class_='wXUyZd').find('a', class_='poRVub').get('href')
            a_list.append(self.url + a)
        return a_list


class Pars_apps:

    def __init__(self, url_apps):
        self.url_apps = url_apps

    def Apps_html(self):
        html = requests.get(self.url_apps, params={'hl': 'ru'})
        return html.text

    def Apps_soup(self):
        soup = BeautifulSoup(self.Apps_html(), 'html.parser')

        try:
            name = soup.find('div', class_='sIskre').find('h1', class_='AHFaub', itemprop='name').find(
                'span').text.strip()
        except:
            name = 'Google'

        try:
            name_company = soup.find('span', class_='T32cc UAO9ie').find('a').text.strip()
        except:
            name_company = 'Google'
        try:
            rewie = soup.find('span', class_='AYi5wd TBRnV').find('span', class_='').text.strip()
        except:
            rewie = '100000'
        try:
            asses = soup.find('div', class_='K9wGie').find('div', class_='BHMmbe').text.strip()
        except:
            asses = '5.0'
        try:
            photo = soup.find('img', class_='T75of DYfLw').get('src')
        except:
            photo = ' Not fond'
        try:
            categor = soup.find_all('span', class_='T32cc UAO9ie')[1].find('a').text.strip()
        except:
            categor = 'Программы'
        try:
            company_a = soup.find('span', class_='T32cc UAO9ie').find('a').get('href')
        except:
            company_a = ''

        dowland = 100000
        try:
            price = soup.find('button', class_='LkLjZd ScJHi HPiPcc IfEcue').text.strip()
        except:
            price = 0
        price_s = price.split()
        if 'Купить' in price_s:
            price = price_s[-2] + price_s[-1]
        else:
            price = 0

        update = '00:00'

        produc_link = 'https://play.google.com'

        produc_email = '[email protected]'

        age_limit = 0

        for i in soup.find_all('div', class_="hAyfc"):
            block = i.find('div', class_='BgcNfc').text.strip()

            if block == 'Обновлено':
                update = i.find('span', class_='htlgb').text.strip()

            if block == 'Количество установок':
                dowland = i.find('span', class_='htlgb').text.strip()

            if block == 'Возрастные ограничения':
                age_limit = i.find('span', class_='htlgb').find('div').find('span', class_='htlgb').text.strip()
            if 'Для всехПодробнее…' in str(age_limit):
                age_limit = 'Для всех'

            if block == 'Разработчик':
                try:
                    produc_link = i.find('a', class_='hrTbp').get('href')
                except:
                    produc_link = None
                try:
                    produc_email = i.find_all('a', class_='hrTbp')[1].text.strip()
                except:
                    produc_email = None

        result = {
            'Name': name,
            'Image': photo,
            'Category': categor,
            'CompanyLink': 'https://play.google.com' + company_a,
            'CompanyName': name_company,
            'DownloadCount': dowland.replace('\\xa', ''),
            'ReviewCount': rewie,
            'Price': price,
            'LastUpdateDate': update,
            'ProducerLink': produc_link,
            'ProducerEmail': produc_email,
            'Rating': asses,
            'AgeLimit': age_limit,
        }

        return result


def index(word, cvs_file):
    result = {
        'id': None,
        'Link': None,
        'Name': None,
        'Image': None,
        'Category': None,
        'CompanyLink': None,
        'CompanyName': None,
        'DownloadCount': None,
        'ReviewCount': None,
        'Price': None,
        'LastUpdateDate': None,
        'ProducerLink': None,
        'ProducerEmail': None,
        'Rating': None,
        'AgeLimit': None,
    }

    session = Search_apps(word)
    res = session.Search_soup()

    number = 0
    dubl = True

    for i in res:

        number += 1
        sesion2 = Pars_apps(i)
        res2 = sesion2.Apps_soup()

        result['Name'] = res2['Name']
        try:
            with open(cvs_file, "r") as f:
                reader = csv.reader(f)
                for row in reader:
                    if row[2] == res2['Name']:
                        print('В таблице есть дубликат ' + res2['Name'])
                        dubl = False
        except FileNotFoundError:
            print('Файл ' + str(cvs_file) + ' не найден')
            print('Создан новый файл ' + str(cvs_file))
        if dubl:
            print('Парситься: ' + str(res2['Name']) + '\t\t' + str(number))
            result['id'] = randint(1000, 999999)
            result['Link'] = i
            result['Image'] = res2['Image']
            result['Category'] = res2['Category']
            result['CompanyLink'] = res2['CompanyLink']
            result['CompanyName'] = res2['CompanyName']
            result['DownloadCount'] = res2['DownloadCount']
            result['ReviewCount'] = res2['ReviewCount']
            result['Price'] = res2['Price']
            result['LastUpdateDate'] = res2['LastUpdateDate']
            result['ProducerLink'] = res2['ProducerLink']
            result['ProducerEmail'] = res2['ProducerEmail']
            result['Rating'] = res2['Rating']
            result['AgeLimit'] = res2['AgeLimit']

            with open(cvs_file, 'a') as file:
                writer = csv.writer(file)
                writer.writerow((result['id'],
                                result['Link'],
                                result['Name'],
                                result['Image'],
                                result['Category'],
                                result['CompanyLink'],
                                result['CompanyName'],
                                result['DownloadCount'],
                                result['ReviewCount'],
                                result['Price'],
                                result['LastUpdateDate'],
                                result['ProducerLink'],
                                result['ProducerEmail'],
                                result['Rating'],
                                result['AgeLimit'],
                                datetime.datetime.now()))
            print('Парсинг закончин: ' + str(res2['Name']) + str(number))
        dubl = True
    number = 0




def main():
    print('Ведите текстовый файл с словами поиска(по умолчанию: word.txt)')
    word = str(input('>'))

    if word == '':
        word = 'word.txt'

    print('Ведите cvs файлы для сохранения(по умолчанию: 389578304.xls)')
    cvs_file = str(input('>'))
    if cvs_file == '':
        cvs_file = '389578304.xls'

    input('Нажмите Enter для запуска программы')

    print('Программа запущена...')
    try:
        words = open(word, 'r')
    except FileNotFoundError:
        print('Файл ' + str(word) + ' не найден')
        exit()
    words_list = []

    for i in words:
        words_list.append(i.replace('\n', ''))
    print('Парсим: ' + str(words_list))

    for i in words_list:
        print('Парсим: ' + str(i))
        index(i, cvs_file)
        print('Парсинг ' + str(i) + ' закончился')
    print('Парсинг закончился')


if __name__ == '__main__':
    system('clear')
    main()

Ответы (0 шт):