开发者

Following redirection and checking IP of website - Ruby

I need to create simple script in Ruby. All I have to do is a check link like this: www.mywebsite.com/redirect.php?=xxx I must check where the link is redirecting me and what exactly is a IP address of new location.

开发者_如何转开发

I've found solution for following redirects in Ruby here: Ruby - net/http - following redirects

But the challenge is, that I do not know how to get current IP after redirect. It is possible to grab it somehow from response object?


You edited your question and said you figured out the redirects. Once you have the URL you got redirected to, you can just use IPSocket.getaddress to find the IP:

>> IPSocket.getaddress 'www.google.com'
=> "209.85.148.104"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜