<?xml version="1.0" encoding="windows-1252"?>
<node id="516864" title="Re: Is it possible to get the redirected URL?" created="2005-12-15 00:21:18" updated="2005-12-14 19:21:18">
<type id="11">
note</type>
<author id="33345">
Kanji</author>
<data>
<field name="doctext">
&lt;p&gt;[cpan://LWP] (or [cpan://WWW::Mechanize]) would let you load Page B and automatically follow the HTTP redirects, with the final URL being available to you in the &lt;tt&gt;uri&lt;/tt&gt; method.&lt;/p&gt;

&lt;p&gt;Where things get tricky is if any of the pages handle redirects via meta refresh or JavaScript.&lt;/p&gt;

&lt;p&gt;The former is pretty easy to [id://447836|code around], but the latter usually requires prior knowledge of what the JavaScript is/does so that you can explictly tailor your code to handle it (and then hope no one changes it).&lt;/p&gt;

&lt;p&gt;If you do expect a lot of JavaScript redirects, a better alternative might be to use either [cpan://Win32::IE::Mechanize] or [cpan://Mozilla::Mechanize], as both browsers have JavaScript engines and should be able to follow those redirects automatically (but I've used neither module, so can't confirm this).&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-33345"&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; --k.&lt;/p&gt;&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
516845</field>
<field name="parent_node">
516845</field>
</data>
</node>
