2012-11-11 36 views
2

只要做一个简单的GET请求whatismyip.org,我每次得到不同的IP。如果它在我的浏览器中访问网站,它总是一样的。这是怎么回事?我只是在我的Windows 7机器上本地运行node.js。我如何使用不同的IP?node.js request.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

+0

您的浏览器配置为使用代理服务器吗?如果您尝试用cURL点击URL,会发生什么情况? –

+0

你看到的IP地址有多不同? – eh9

+0

真的不一样,你知道吗。我试过'http:// whatismyipaddress.com',每次都是我的IP。我认为'http:// www.whatsmyip.org'实际上是在拖我......任何人都可以证实这一点? –

回答

1

它看起来像网站使用JavaScript来更新页面上的跨度,所以如果你正在做一个简单的HTTP请求,然后是将不会更新为正确的值。如果您使用Web浏览器访问该站点,但只查看源代码(不使用任何更新的检查器)并刷新,则显示的IP似乎是随机的。

1

阅读HTML注释正确的IP地址上面:

<!-- 
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!! 
--> 
+0

这很酷,我没有使用任何机器人。只要做一些测试就可以了。 –

相关问题