Python,學霸
大家好!今天給你們帶來了透過requests爬取steam優惠遊戲列表python例項,僅供學習!
安裝:
pip install requests
例項:
import requests
from bs4 import BeautifulSoup
url = 'https://store.steampowered.com/search/?specials=1'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
title_spans = soup.find_all('span', class_='title')
price_div = soup.find_all('div', class_='discount_prices')
for span,price in zip(title_spans,price_div):
print(span.text,price.get_text(separator='|||', strip=False))
輸出:
Darkest Dungeon®: Ancestral Edition ¥216.00|||¥30.51
Cyberpunk 2077 ¥298.00|||¥149.00
Cyberpunk 2077: Ultimate Edition ¥447.00|||¥253.60
Darkest Dungeon® ¥92.00|||¥9.20
The Witcher 3: Wild Hunt - Complete Edition ¥199.00|||¥49.75
Grand Theft Auto V: Premium Edition ¥179.00|||¥65.40
Grand Theft Auto V ¥179.00|||¥65.40
Tomb Raider Definitive Survivor Trilogy ¥992.00|||¥64.31
The Witcher® 3: Wild Hunt ¥149.00|||¥37.25
Cyberpunk 2077: Phantom Liberty ¥149.00|||¥126.65
Assassin's Creed® Odyssey ¥298.00|||¥59.60
Assetto Corsa Competizione ¥138.00|||¥34.50
Knowledge, or know Lady ¥36.00|||¥32.40
Kenshi ¥90.00|||¥29.70
Planet Zoo ¥180.00|||¥45.00
Overcooked! 2 ¥98.00|||¥24.50
Bloons TD 6 ¥47.00|||¥9.40
No Man's Sky ¥175.00|||¥87.50
Green Hell & Official Soundtrack Bundle ¥86.00|||¥28.38
Darkest Dungeon®: The Crimson Court ¥42.00|||¥10.50
Black Reliquary Bundle ¥152.00|||¥24.20
Evil Genius 2: World Domination ¥116.00|||¥5.80
Tom Clancy's Ghost Recon® Wildlands ¥248.00|||¥49.60
Living With Sister: Monochrome Fantasy ¥39.00|||¥31.20
BlazBlue Entropy Effect ¥76.00|||¥59.28
Satisfactory ¥99.00|||¥49.50
DEATH STRANDING DIRECTOR'S CUT ¥108.00|||¥54.00
Goat Simulator 3 ¥147.00|||¥29.40
Rise of the Tomb Raider™ ¥441.00|||¥48.51
Shadow of the Tomb Raider: Definitive Edition ¥298.00|||¥199.66
Football Manager 2024 ¥1,085.72|||¥374.83
Uninitialized ¥109.00|||¥32.70
Planet Zoo: Ultimate Edition ¥18.00|||¥5.40
Uninitialized ¥88.00|||¥50.16
Dying Light Enhanced Edition ¥109.00|||¥32.70
Muse Dash ¥58.00|||¥52.20
Senren*Banka ¥42.00|||¥33.60
Dying Light ¥22.00|||¥5.50
Feed the Cups ¥468.00|||¥208.80
Deep Rock Galactic: Survivor ¥18.00|||¥4.50
Darkest Dungeon®: The Color Of Madness ¥378.00|||¥302.40
GT Racing Game Bundle ¥70.00|||¥21.00
Darkest Dungeon®: The Shieldbreaker ¥163.00|||¥40.75
ARK Upgrade Bundle ¥96.00|||¥86.40
Tribes of Midgard ¥228.00|||¥148.20
Jurassic World Evolution 2 ¥42.00|||¥4.20
Can't Put it Down Bundle ¥78.00|||¥68.64