首页 > 解决方案 > 使用 Python request.get 参数,但它给了我错误的 url

问题描述

我正在尝试使用 Python 请求库从 Steam 中删除一些数据。但首先我需要修改我的网址

例如,如果我想访问带有标签的游戏

https://store.steampowered.com/search?tags=7743%2C3871

这是我需要的链接。但是当我这样做时

steam_url = "https://store.steampowered.com/search?"
search = request.get(steam_url, params = {'tags' : [7743, 3871]})

我得到这个网址

https://store.steampowered.com/search?tags=7743&tags=3871

仅向我展示 2D 游戏 [id : 3871]

为了解决这个问题,我试图这样做

steam_url = "https://store.steampowered.com/search?"
search = get(steam_url, params = {'tags' : '%2C'.join(list(map(str,[7743, 3871])))})

然后我得到这个网址

https://store.steampowered.com/search?tags=7743%252C3871

我不明白为什么这些 id 之间有%252C 。

我应该怎么办?

标签: pythonpython-requests

解决方案


我不明白为什么这些 id 之间有 %252C。

因为您正在使用which'%2C'.join被转义为百分号。使用并让做转义。%252C%25','.joinrequests.get


推荐阅读