Не парсится сайт epicgames /store/ru/free-games с помощью BeautifulSoup

Я хочу парсить бесплатные игры на epicgames store по ссылке: https://www.epicgames.com/store/us/free-games, но мне вместо этого выдает статус код: 403, что делать? Код:

import requests
from bs4 import BeautifulSoup as Bs

URL = "https://www.epicgames.com/store/us/free-games"

r = requests.get(URL)
print(r.status_code)
soup = Bs(r.content, 'html.parser')
nm = soup.find_all("h6", class_='eds_1ypbntd0 eds_1ypbntd7 eds_1ypbntdq')
for i in nm:
    print(i)

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

Автор решения: LowpolyOllie

На этом сайте используется cloudflare, который легко палит искусственные запросы. Один из вариантов как это спарсить - посмотреть в браузере в devtools/networking, куда уходит запрос на список бесплатных игр, и попробовать постучать в API напрямую. Вот вариант с использованием Selenium:

from selenium import webdriver
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup as Bs
import json

firefox_options = webdriver.FirefoxOptions()
firefox_options.add_argument('--headless')
firefox_options.set_preference('devtools.jsonview.enabled', False)
firefox_options.binary_location = '...' #Локация бинарника браузера

service = webdriver.FirefoxService(executable_path='...') #Локация бинарника драйвера
driver = webdriver.Firefox(service=service, options=firefox_options)

base_url = 'https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions?locale=ru&country=RU&allowCountries=RU'

driver.get(base_url)
content = driver.page_source
driver.close()

soup = Bs(content, 'html.parser')

free_games_json = json.loads(soup.text)
free_games_titles = [
    x['title']
    for x in free_games_json['data']['Catalog']['searchStore']['elements']
]

print(free_games_titles)
>>> ['ScourgeBringer', "Them's Fightin' Herds",'Model Builder: Complete Edition','Zoeti','Eternal Threads','Ghostrunner 2','Monument Valley','Songs of Silence']
→ Ссылка