我正在尝试使用 Python 请求库从 Steam 中删除一些数据。但首先我需要修改我的网址
例如,如果我想访问带标签的游戏
- 二维 [id:3871]
- 1980 年代 [id:7743]
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。
我应该做什么?
最佳答案
I couldn't understand why there is %252C between those ids.
因为您使用的是 '%2C'.join
,它会转义为 %252C
,其中 %25
是百分号。使用 ','.join
并让 requests.get
进行转义。
关于python - 使用Python request.get param 但它给了我错误的url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52578774/