F12 -> видим, что запрос нужно отправлять по адресу "
https://store.steampowered.com/search/results?term=", например - "
https://store.steampowered.com/search/results?term..."
И ещё можно вынести парсинг в отдельную функцию, чтобы было проще отлаживать:
from bs4 import BeautifulSoup
import requests
def search_game(title):
URL = 'https://store.steampowered.com/search/results'
games_list = []
response = requests.get(URL,params={'term':title},headers={'user-agent':'hacked by hottabXP'})
soup = BeautifulSoup(response.text,'lxml')
games = soup.find('div', id='search_resultsRows').find_all('a',class_='search_result_row ds_collapse_flag')
for game in games:
title = game.find('span',class_='title').text.strip()
try: # На случай, если цена со скидкой
price = game.find('div',class_='col search_price responsive_secondrow').text.strip()
except:
price = game.find('strike').text
games_list.append({'title':title,'price':price})
return games_list
print(search_game("GTA 5"))
[{'title': 'Grand Theft Auto V', 'price': ''}, {'title': 'Grand Theft Auto V: Premium Edition', 'price': '629₴'}, {'title': 'Grand Theft Auto V: Premium Edition & Great White Shark Card Bundle', 'price': '790₴'}, {'title': 'Grand Theft Auto V: Premium Edition & Megalodon Shark Card Bundle', 'price': '1 228₴'}, {'title': 'GTA Online: Shark Cash Cards', 'price': ''}, {'title': 'Grand Theft Auto V - Criminal Enterprise Starter Pack', 'price': '209₴'}, {'title': 'Grand Theft Auto V: Premium Edition & Whale Shark Card Bundle', 'price': '916₴'}, {'title': 'liteCam Game 5: 120 FPS Game Capture + Streamer', 'price': ''}, {'title': 'Assetto Corsa - Dream Pack 1', 'price': '129₴'}, {'title': 'Warhammer 40,000: Dawn of War III', 'price': '599₴'}, {'title': 'Memory Card Monsters - Expanded Content 5', 'price': '21₴'}, {'title': 'Fantasy Memory Card Game - Expansion Pack 5', 'price': '21₴'}, {'title': 'APB Reloaded', 'price': 'Free to Play'}, {'title': 'Shop Tycoon: Prepare your wallet', 'price': '119₴'}, {'title': '3dSunshine', 'price': 'Free'}, {'title': 'Druid', 'price': '20₴'}, {'title': 'Lazaretto', 'price': '129₴'}, {'title': "Rock 'N' Roll Defense", 'price': '21₴'}, {'title': '小黑盒加速器', 'price': 'Free To Play'}, {'title': 'Drop Hunt - Adventure Puzzle', 'price': '20₴'}, {'title': 'Carmageddon Max Pack', 'price': '169₴'}, {'title': 'Lamp Head', 'price': '27₴'}, {'title': 'Need for Drive - Open World Multiplayer Racing', 'price': '21₴'}, {'title': 'Crash Drive 3', 'price': '279₴'}, {'title': 'Retro City Rampage™ DX', 'price': '229₴'}, {'title': 'VCB: Why City 4k', 'price': '67₴'}, {'title': 'CS2D', 'price': 'Free To Play'}, {'title': 'ConflictCraft', 'price': '21₴'}, {'title': 'State of Anarchy: Master of Mayhem', 'price': '20₴'}, {'title': 'Geneshift', 'price': '229₴'}, {'title': '汉武大帝传', 'price': '149₴'}, {'title': 'Fix Me Up Doc! – Dark Humor', 'price': '21₴'}, {'title': 'Extreme Racing on Highway', 'price': '179₴'}, {'title': 'The Last Hope: Trump vs Mafia - North Korea', 'price': '21₴'}, {'title': 'Control Craft 3', 'price': '21₴'}, {'title': 'Zombie Killer Drift - Racing Survival', 'price': '21₴'}, {'title': 'Bugs Must Die / 异星特勤队', 'price': '199₴'}, {'title': 'Control Craft 2', 'price': '21₴'}, {'title': 'Hero Hunters - 杀手 3D 2K19', 'price': '119₴'}, {'title': 'USA Truck Simulator', 'price': '27₴'}, {'title': 'MechDefender - Tower Defense', 'price': '21₴'}, {'title': 'CYBER.one: Racing For Souls', 'price': ''}, {'title': 'VCB: Why City (Beta Version)', 'price': ''}, {'title': 'Mountain Taxi Driver', 'price': '21₴'}, {'title': 'The Kickstarter Avoidance Album', 'price': '21₴'}, {'title': 'Dino Zoo Transport Simulator', 'price': '27₴'}, {'title': 'Snow Clearing Driving Simulator', 'price': '169₴'}, {'title': 'Space Hero Line', 'price': '21₴'}, {'title': 'EDEN STAR', 'price': '279₴'}, {'title': 'liteCam Game: 100 FPS Game Capture', 'price': ''}]