无法使用请求模块

时间:2016-01-19 16:33:21

标签: javascript node.js ascii steam steambot

我正在使用node.js(http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=)中的请求模块从官方API下载Steam项目的价格,并且除了名称以星号(★)开头的项目然后网址的情况下它工作得非常好节点处理的外观是http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=★%20M9%20Bayonet%20%7C%20Stained%20(Field-Tested)。当手动键入浏览器时,它运行良好,但当我的Steam机器人执行此操作时,Steam返回{"success":"false"}。我认为它没有通过星号(★)的原因,我应该如何解决它?

1 个答案:

答案 0 :(得分:1)

在将market_hash_name传递给request库之前对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) }); 进行完全网址编码。

<div id="partial-customertype-personal">
    <div class="form-group col-xs-3 col-md-3">
        <label for="customernumberF" class="control-label">Customer Number (F)</label>
        <input type="text" class="form-control" id="customer-numberF" name="customer-numberF" maxlength="9" />
</div>
<div class="form-group col-xs-5 col-md-5">
    <label for="surname" class="control-label">Surname</label>
    <input type="text" class="form-control" id="surname" name="surname" maxlength="50" />
</div>
<div class="form-group col-xs-2 col-md-2">
    <label for="datebirth" class="control-label">Date of Birth</label>
    <div class="input-group date" id="datetimepicker1">
        <input type="text" class="form-control" id="date-birth" name="date-birth" maxlength="10" />
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
    </div>                      
</div>
<div class="form-group col-xs-2 col-md-2">
    <label for="postcode" class="control-label">Post Code</label>
    <input type="text" class="form-control" size="4" id="post-code" name="post-code" maxlength="8" />
</div>