Who says those pages are doing redirects? What if the first web page
parses the query string attached to the url, then uses javascript to
load a different page?
If the first page is redirecting using Javascript client side perhaps
you
should consider using PhantomJS through the phantomjs.rb gem or other
equivalent mean.
To assert before which way the redirection actually happens, I’d try
with a
browser plugin like Live HTTP Headers or good old Wireshark.
Still, the op’s question remains unanswered: why doesn’t open-uri follow
all those redirects?
Looking at the curl -Lv output, there are cookies being set. Maybe a
server side script kicks you out if the requests for the redirect urls
do not include those cookies? But then again, curl was able to follow
all the redirects without employing the --cookie-jar option.
Another option is to try Mechanize and see if it can follow all the
redirects.
And for anyone that clicked on those nasty links, feel free to remove
the tracking cookies with these domain names:
Still, the op’s question remains unanswered: why doesn’t open-uri follow
all those redirects?
it can:
% ri OpenURI::OpenRead#open | grep -A8 :redirect:
:redirect:
Synopsis:
:redirect=>bool
:redirect=>false is used to disable HTTP redirects at all.
OpenURI::HTTPRedirect exception raised on redirection. It is true by
default.
The true means redirections between http and ftp is permitted.
Still, the op’s question remains unanswered: why doesn’t open-uri follow
all those redirects?
it can:
The docs don’t make a lot of sense to me (but I’m not surprised anymore
by how crappy the ruby docs are). open-uri follows redirects by
default, and throws an exception on redirect? How are both of those
true? In any case, I don’t get an exception–I get:
Still, the op’s question remains unanswered: why doesn’t open-uri follow
all those redirects?
it can:
According to the docs, open-uri follows redirects by default. So
according to the docs, open-uri can follow redirects, but the fact
remains it doesn’t in this case. Why?
Because it redirects with invalid URI’s:
Last login: Fri Sep 7 23:45:55 on ttys008
10000 % ruby -ropen-uri -e ‘URI.parse(ARGV.shift).read’
“OOPS! The offer you're looking for has expired.”
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:436:in split': bad URI(is not URI?): http://www.apmebf.com/l8122ar-zH/ry2/GFKINFIM/KIHOOGI/F/F/F?b=k1ys%3Do00w%25AH%259M%259M333.Dwt.jvt%259Myvjr-u-yvss-jv3npys-3v2lu-01upj-ylk<<o00w%3A%2F%2F333.qkvxvj5.jvt%3AF7%2Fjspjr-CA9GG8A-87CAF7AE<<N<< (URI::InvalidURIError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:485:in parse’
…
from -e:1
10001 % curl -I !$
curl -I
“OOPS! The offer you're looking for has expired.”
HTTP/1.1 302 Found
Server: Resin/3.1.8
P3P: policyref=“http://www.jdoqocy.com/w3c/p3p.xml”, CP=“ALL BUS LEG DSP
COR ADM CUR DEV PSA OUR NAV INT”
Cache-control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Expires: Sat, 08 Sep 2012 06:48:03 GMT
Location: OOPS! The offer you're looking for has expired.<<v773%3A%2F%2FAAA.xr242qC.q20%3AME%2Fqzwqy-JHGNNFH-FEJHMEHL<<U<<
Content-Type: text/html
Connection: close
Date: Sat, 08 Sep 2012 06:48:03 GMT
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.