node.js request.js为什么我的IP地址会改变?

时间:2012-11-11 03:43:18

标签: node.js http request

只是对whatismyip.org做一个简单的GET请求,每次都得到一个不同的IP。如果它在我的浏览器中访问该网站,它总是一样的。怎么了?我只是在我的Windows 7机器上本地运行node.js。我怎么可能使用不同的IP?

request('http://www.whatsmyip.org/', function (error, response, body) {
    if (!error && response.statusCode == 200) {
        res.render('index', {content:body;});
    }
});

我觉得http://www.whatsmyip.org知道这是一个自动请求并且在拖我。的xD

2 个答案:

答案 0 :(得分:1)

阅读IP地址正上方的HTML评论:

<!--
Please DO NOT program a bot to use this site to grab your IPs. It kills my server and thats not nice.
Just get some cheap or free web hosting and make your own IP-only page to power your bot.
Then you won't even have to parse any html, just load the IP directly - better for everyone!!
-->

答案 1 :(得分:1)

看起来网站正在使用JavaScript来更新页面上的跨度,因此如果您正在执行简单的HTTP请求,那么将不会更新为正确的值。如果您使用Web浏览器访问该站点但只查看源(不使用任何更新的检查器)并刷新,则显示的IP似乎是随机的。

相关问题