Hey monks... I've not been here in a long while. In fact, I've been cheating on you by using PHP in one of my larger projects. I know, tsk tsk. I do use Perl at work on admittedly rather menial stuff day in day out though. Anyhoo...

Long story short I'm using Curl in PHP to do the following:
Slurp -> Find Link to Login page, and follow -> Find login form and follow -> Reslurp original page (but logged in).
This worked fine and dandy until a change on the server side, which I have determined now checks for Javascript and forces a Captcha in the case that it is disabled. If I disable javascript in any single step of the above sequence in a browser, the Captcha is forced. I'm using HttpFox to look at the packets, and it seems that cookies are written in a pretty standard fashion. (I get two in response to the first slurp, which uses GET). In a browser w/ JavaScript enabled, I get another 5 or so after I follow the login form. The headers being sent are identical in the browser & the Curl script, but Curl ignores the javascripts of course. I know the magic is somehow set in either a <script> tag or a <noscript> tag. If Javascript is enabled I get a very non-trivial script, plus about 5 cookies. I don't know if it does anything but it can't be ignored. It's 189k, and relatively daunting. When I follow the login form w/ my Curl PHP script (w/ JS obviously unavailable) the scripts are ignored, I get no cookies, and the captcha appears. So, I'm now weighing my options.

*A long time ago I did something similar with WWW::Mechanize, and I'm not totally opposed to doing it now. I see there is a JavaScript plugin (I think this is relatively new). I'm curious as to how it works though. Can I be somewhat sure that the server side will assume I'm a browser w/ JS enabled if I use the plugin?

*How could the server side be internally storing whether I am using Javascript or not? I assume a JavaScript the browser has executed could access some URL which would then store whether I'm a browser or a scraper.

*Any other one I'm not thinking of?

Cheers for any advice!

In reply to Mechanize, Javascript, Cookies, and you! by GaijinPunch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.