0

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?

irqize
  • 97
  • 1
  • 10
  • 1
    Since the URL from the browser works, you can always just open up the network tab in the debugger and see exactly what encoded URL is being sent to the server there to see how your URL is different than that. – jfriend00 Jan 19 '16 at 17:24

1 Answers1

1

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)
});
Adam Lamers
  • 1,183
  • 7
  • 8