由于库存波动,在欧洲获得翻新的 Steam Deck 可能具有挑战性。这个基于 Python 的可用性检查器可自动执行该过程,并在出现翻新设备时提供实时通知。 这篇文章详细介绍了该项目的技术实现并鼓励社区贡献。
项目概览
此 Python 脚本监视 Steam 商店在欧洲是否有翻新的 Steam Deck。 利用 ntfy 通知服务,当库存有货时,它会立即提醒用户。 该项目展示了如何使用现成的 Python 库和 API 来高效解决问题。
功能
脚本运行如下:
核心逻辑:
<code class="language-python">from urllib.request import urlopen # Configure your ntfy URL ntfy_url = "ntfy.sh/YOUR_NTFY_URL" # Timeout to prevent script hang-ups timeout = 8 def parse_availability(data: bytes) -> bool: parsed = " ".join(f"{c:02X}" for c in data) not_available = "08 00 10 00" return parsed != not_available def is_available(id_: str) -> bool: url = ( "api.steampowered.com/IPhysicalGoodsService/" "CheckInventoryAvailableByPackage/v1?origin=" f"https://store.steampowered.com&input_protobuf_encoded={id_}" ) with urlopen(f"https://{url}", timeout=timeout) as response: data = response.read() return parse_availability(data) def notify(name: str) -> None: message = f"Refurbished {name} Steam Deck is available!" print(message) with urlopen(f"https://{ntfy_url}", data=str.encode(message), timeout=timeout): pass if __name__ == "__main__": # Uncomment for notification testing # notify("TEST") # Refurbished 64GB (European region, tested in Poland) if is_available("COGVNxICUEw="): notify("64GB")</code>
执行
ntfy_url
替换为您的个人 ntfy URL(从 ntfy 网站获取一个)。 建议使用ntfy移动应用程序进行通知。ntfy.sh
和 api.steampowered.com
添加到 Internet Explorer 设置中的受信任站点。结论
该项目强调了简洁的 Python 脚本在实际任务中的强大功能。它是 API 交互、通知和 Python 自动化的宝贵学习资源。 完整代码在GitHub上,欢迎贡献和定制。
以上是为欧洲翻新蒸汽甲板构建可用性检查器的详细内容。更多信息请关注PHP中文网其他相关文章!