Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们有一堆围绕 Mojo::UserAgent 构建的代码,迁移到 MojoX::UserAgent 并不是一个很好的选择。我想知道是否有办法在 Mojo::UserAgent 中获取/设置用户代理字符串?
当前(Mojo 4.5)方式是:
# Change name of user agent $ua->transactor->name('MyUA 1.0');
请参阅此处的CPAN 文档。
使用name访问器:
name
my $name = $ua->name; $ua->name('Mozilla/5.0');
(请注意,在 4.x 版本中,名称访问器已被删除)