Hinnerk Altenburg

Web Developer in Hamburg, Germany

Archive for the ‘CPAN’ tag

Set a custom HTTP User-Agent in Perl with WWW::Mechanize

with 2 comments

This is how you can dynamically set a custom HTTP User-Agent for your Perl requests to fake a device or browser for testing purpose or getting a device-specific version of a website.
WWW::Mechanize supports setting a custom user-agent with the constructor and after this gives a choice of 6 pre-defined basic user-agents ( $mech->agent_alias() ), only.

The following code demonstrates how to dynamically change the user-agent on a Mechanize object.

Written by Hinnerk

Juni 29th, 2011 at 9:21 pm

Posted in English

Tagged with , , , , ,