selenium 设置指定分辨率

code

import time
from selenium import webdriver

WIDTH = 320  # 宽度
HEIGHT = 640  # 高度
PIXEL_RATIO = 3.0  # 分辨率

mobileEmulation = {"deviceMetrics": {"width": WIDTH, "height": HEIGHT, "pixelRatio": PIXEL_RATIO}}
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation', mobileEmulation)

driver = webdriver.Chrome(chrome_options=options)
driver.get('http://m.baidu.com')

time.sleep(3)
driver.close()

原文地址:https://www.cnblogs.com/sea-stream/p/14262314.html