python selenium Chrome 设置为手机模式

时间:2018-02-06 20:14:47   收藏:0   阅读:1384

# -*- coding: utf-8 -*-

from selenium import webdriver

from time import sleep

mobileEmulation = {‘deviceName‘: ‘Apple iPhone 4‘} options = webdriver.ChromeOptions()

options.add_experimental_option(‘mobileEmulation‘, mobileEmulation)

driver = webdriver.Chrome(executable_path=‘chromedriver.exe‘, chrome_options=options)

driver.get(‘http://m.baidu.com‘)

sleep(3)

driver.close()

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!