当前位置: 欣欣网 > 码农

Python爬取steam优惠游戏列表

2024-04-02码农

Python,学霸

大家好!今天给你们带来了通过requests爬取steam优惠游戏列表python实例,仅供学习!

安装:

pip install requests

实例:

import requestsfrom bs4 import BeautifulSoupurl = '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.51Cyberpunk 2077 ¥298.00|||¥149.00Cyberpunk 2077: Ultimate Edition ¥447.00|||¥253.60Darkest Dungeon® ¥92.00|||¥9.20The Witcher 3: Wild Hunt - Complete Edition ¥199.00|||¥49.75Grand Theft Auto V: Premium Edition ¥179.00|||¥65.40Grand Theft Auto V ¥179.00|||¥65.40Tomb Raider Definitive Survivor Trilogy ¥992.00|||¥64.31The Witcher® 3: Wild Hunt ¥149.00|||¥37.25Cyberpunk 2077: Phantom Liberty ¥149.00|||¥126.65Assassin's Creed® Odyssey ¥298.00|||¥59.60Assetto Corsa Competizione ¥138.00|||¥34.50Knowledge, or know Lady ¥36.00|||¥32.40Kenshi ¥90.00|||¥29.70Planet Zoo ¥180.00|||¥45.00Overcooked! 2 ¥98.00|||¥24.50Bloons TD 6 ¥47.00|||¥9.40No Man's Sky ¥175.00|||¥87.50Green Hell & Official Soundtrack Bundle ¥86.00|||¥28.38Darkest Dungeon®: The Crimson Court ¥42.00|||¥10.50Black Reliquary Bundle ¥152.00|||¥24.20Evil Genius 2: World Domination ¥116.00|||¥5.80Tom Clancy's Ghost Recon® Wildlands ¥248.00|||¥49.60Living With Sister: Monochrome Fantasy ¥39.00|||¥31.20BlazBlue Entropy Effect ¥76.00|||¥59.28Satisfactory ¥99.00|||¥49.50DEATH STRANDING DIRECTOR'S CUT ¥108.00|||¥54.00Goat Simulator 3 ¥147.00|||¥29.40Rise of the Tomb Raider™ ¥441.00|||¥48.51Shadow of the Tomb Raider: Definitive Edition ¥298.00|||¥199.66Football Manager 2024 ¥1,085.72|||¥374.83Uninitialized ¥109.00|||¥32.70Planet Zoo: Ultimate Edition ¥18.00|||¥5.40Uninitialized ¥88.00|||¥50.16Dying Light Enhanced Edition ¥109.00|||¥32.70Muse Dash ¥58.00|||¥52.20Senren*Banka ¥42.00|||¥33.60Dying Light ¥22.00|||¥5.50Feed the Cups ¥468.00|||¥208.80Deep Rock Galactic: Survivor ¥18.00|||¥4.50Darkest Dungeon®: The Color Of Madness ¥378.00|||¥302.40GT Racing Game Bundle ¥70.00|||¥21.00Darkest Dungeon®: The Shieldbreaker ¥163.00|||¥40.75ARK Upgrade Bundle ¥96.00|||¥86.40Tribes of Midgard ¥228.00|||¥148.20Jurassic World Evolution 2 ¥42.00|||¥4.20Can't Put it Down Bundle ¥78.00|||¥68.64