Search code examples
javascriptnode.jsasciisteamsteambot

Can't process url with request module


I'm downloading price of Steam item from official API using request module in node.js (http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=) and it works very well except case when item, whose name starts with star symbol (★), then url looks processed by node is http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=★%20M9%20Bayonet%20%7C%20Stained%20(Field-Tested). When type it manually to browser it works well, but when my Steam bot does it, Steam returns {"success":"false"}. I think the reason it doesn't pass the star symbol (★), how should i fix it?


Solution

  • Fully URLencode the market_hash_name before passing it to the request library.

    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)
    });