Subject: | Use a more genereal User-Agent by default |
Some sites need to see the "Mozilla" or "MSIE" in the User-Agent to work correctly so I patched my copy of WWW::Mechanize to use "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" instead of "WWW-Mechanize/$VERSION" by default.
I know that can be changed at runtime with:
my $agent = WWW::Mechanize->new( agent=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" );
But it's a pain when I have to update the agent string on so many programs.
As WWW::Mechanize tries to mimic popular browsers the User-Agent string should contain at least the "Mozilla" and "MSIE" words. Another example would be "Mozilla/4.0 (compatible with MSIE 6.0; Windows NT 5.1)"
--- WWW/Mechanize.pm~
+++ WWW/Mechanize.pm
@@ -126,7 +126,7 @@
The constructor for WWW::Mechanize overrides two of the parms to the
LWP::UserAgent constructor:
- agent => "WWW-Mechanize/#.##"
+ agent => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
cookie_jar => {} # an empty, memory-only HTTP::Cookies object
You can override these overrides by passing parms to the constructor,
@@ -145,7 +145,7 @@
my $class = shift;
my %default_parms = (
- agent => "WWW-Mechanize/$VERSION",
+ agent => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
cookie_jar => {},
);