Using open-uri how can I get the contents of a redirecting page?

Posted by Shpigford on Stack Overflow See other posts from Stack Overflow or by Shpigford
Published on 2010-05-03T15:18:49Z Indexed on 2010/05/03 18:38 UTC
Read the original article Hit count: 396

Filed under:
|
|

I ultimately want to get data from this page:

http://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?trackingNumber=0656887000494793

But that page forwards to:

http://www.canadapost.ca/cpotools/apps/track/personal/findByTrackNumber?execution=eXs1

So when I use open (open-uri) to try and fetch the data, it throws a RuntimeError error saying HTTP redirection loop:

So I'm not really sure how to get that data after it redirects and throws that error.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about open-uri