0

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?

Community
  • 1
  • 1
Arti
  • 407
  • 5
  • 15

1 Answers1

0

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"
Michael Kohl
  • 66,324
  • 14
  • 138
  • 158