Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, using mechanize to get a web page - darn thing redirects to download page if browser is not Firefox. I tried $mech->agent_alias('Firefox/3.5.7'); but it's not fooled! Anyone know what I can use? Thanks

Replies are listed 'Best First'.
Re: Firefox user agent in mechanize
by marto (Cardinal) on Jun 03, 2010 at 15:58 UTC

    Read the WWW::Mechanize docs, it lists the valid user agents. 'Firefox/3.5.7' isn't a valid user agent alias string. See also Firefox User Agent Strings.

    Update: Yes, I messed up, I meant to say'Firefox/3.5.7' isn't a valid user agent alias, rather than string. Thanks ikegami

      You mean it's not a valid user agent alias. It is a valid user agent string, which means it could be passed to ->agent(), but it's not one Firefox uses. You can get some agent string used by Firefox on this page.

        Ugg, yeah, thanks for the correction. My fault for doing too many things at once.

      golly, that's a nice link -thank you
Re: Firefox user agent in mechanize
by jonnyfolk (Vicar) on Jun 03, 2010 at 16:03 UTC
    $mech->agent('User-Agent=Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.7');
      That worked very nicely - thankee kindly