如何更改用户代理

How do I change the user agent?

本文关键字:用户代理 何更改      更新时间:2023-09-26

我在phantom上遇到了麻烦,phantomjs周围的节点包装器

在本地的phantomjs中就是这样做的。

page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';

快速搜索在GitHub上找到了一个线程,看起来你需要使用page.set,例如

page.set('settings.userAgent', 'new useragent');

或当选择多个设置时,

page.set('settings', {
    userAgent: 'new useragent',
    javascriptEnabled: true,
    loadImages: true
});