使用Splinter在PhantomJS中渲染桌面视图而不是Mobile-view

时间:2015-11-18 06:26:39

标签: python selenium-webdriver phantomjs render splinter

我正在使用Splinter(https://splinter.readthedocs.org) PhantomJS驱动程序,作为我使用的useragent:

  

Mozilla / 5.0(X11; U; Linux x86_64; en-US; rv:1.9.0.3)Gecko / 2008092814(Debian-3.0.1-1)

在ghostdriver日志文件中,我可以看到PhantomJS使用了用户代理。 页面由浏览器呈现,但在拍摄不同的屏幕截图时 我浏览的页面,我可以观察到它们是为移动设备呈现的,并且没有加载仅在普通网页版本中显示的页面项目。

创建Splinter Browser对象的实例时,是否需要为PhantomJS webdriver指定特定参数?

1 个答案:

答案 0 :(得分:0)

您应该为PhantomJS设置桌面分辨率。 基于Splinter上的another question

from splinter import Browser

with Browser() as browser:

    # Optional, but make sure large enough that responsive pages don't
    # hide elements on you...
    browser.driver.set_window_size(1280, 1024)