我正在使用node.js (http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=)中的请求模块从官方API下载Steam元素的价格,它工作得很好,除了元素名称以星号(★)开头,然后url看起来已处理的情况按 Node 为http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=★%20M9%20Bayonet%20%7C%20Stained%20(经过现场测试)
。当在浏览器中手动输入时,效果很好,但当我的 Steam 机器人执行此操作时,Steam 返回 {"success":"false"}
。我认为它没有通过星号(★)的原因,我应该如何解决它?
最佳答案
在将market_hash_name
传递给request
库之前对其进行完全URL编码。
request = require("request")
request("http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=%e2%98%85+M9+Bayonet+%7c+Stained+(Field-Tested)", function(e, response, body) {
console.log(body)
});
关于javascript - 无法使用请求模块处理 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34882068/