I'm trying to use WWW::Mechanize to navigate through a site and ultimately download a report each day. After I get within one screen of where I need to go, the HTML contains JavaScript that sets 4 cookies and uses an onclick button handler to jump to the screen I need. The problem I'm running into is that the 4 cookies repeat the same name twice, like:
<script language="JavaScript" type="text/javascript">
// Set cookies
document.cookie = "Report_Profile_ID=654321;path=/cgi-bin\";
document.cookie = "Report_Profile_ID=654321;path=/actuate";
document.cookie = "FirstTime=1;path=/cgi-bin";
document.cookie = "FirstTime=1;path=/actuate";
// end cookie set
</script>
I tried to fake the JavaScript cookie setting by grabbing the cookie values from the JavaScript source and simply setting these cookies in the $agent->cookie_jar.
Unfortunately, HTTP::Cookies->set_cookie() appears to simply overwrite a previous cookie having the same name, rather than saving an array of values for a cookie of a given name. So now I'm kinda stuck. Can the perluminati suggest a way my script can provide more than one cookie having the same name?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.