2
我在为幻像页设置自定义用户代理时遇到问题。我已经寻找可能的解决方案,但我似乎错过了应该如何工作的一些基本部分,因为当我尝试设置我的设置时,我的幻影挂起,并没有完成请求或进入page.open方法。这里是我的代码:使用PhantomJS w/Node并设置自定义UserAgent
phantom.create().then(function(ph) {
ph.createPage().then(function(page) {
page.set('settings.userAgent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.256');
page.open(req.cookies.website).then(function(status) {
page.property('content').then(function(content) {
res.send(content);
page.close();
ph.exit();
});
});
});
});