简体   繁体   English

如何更改 PhantomJS 的屏幕分辨率?

[英]How can I change the screen resolution of PhantomJS?

In any way I can not find a question concerning change of the sanction of the screen.无论如何,我找不到有关更改屏幕制裁的问题。 There will always be 1024x768 .总会有1024x768 Changing the viewportSize does not change the screen resolution, by itself.更改 viewportSize 本身不会更改屏幕分辨率。 I checked the resolution here: link我在这里检查了分辨率:链接

This is for node:这是节点:

var WebPage = require('webpage');
page = WebPage.create()

page.onInitialized = function () {
    page.evaluate(function () {
        window.screen = {width: 1600, height: 900, availWidth: 1600, availHeight: 900};
    });
};

page.open('http://browserspy.dk/screen.php');
page.onLoadFinished = function () {
    page.render('ScreenShot' + '.png');
    phantom.exit();
}

Can anyone remake for the python?任何人都可以为python重新制作吗?

Try using viewportSize.尝试使用视口大小。 Refer this link ViewPortSize请参阅此链接ViewPortSize

var webPage = require('webpage');
var page = webPage.create();

page.viewportSize = {
  width: 480,
  height: 800
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM