【发布时间】:2021-12-27 16:44:22
【问题描述】:
我正在尝试获取商品StatTrak™ Dual Berettas | Panther (Factory New) 的价格。但是 TM 会导致问题,因为 urllib 将其视为非 ascii 字符。我找到了这个How to fetch a non-ascii url with urlopen?,但无论出于何种原因,steam 都出现了 500 错误
from urllib.parse import quote
def get_price(item_name):
base_url = 'http://steamcommunity.com/market/priceoverview/?appid=730¤cy=1&market_hash_name={}'
print(base_url.format(quote(item_name)))
request = urllib.request.urlopen(base_url.format(quote(item_name)))
我似乎需要通过这个,但 urllib 不允许我通过。我能做什么?
【问题讨论】:
标签: python url encoding urllib