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"
精彩评论