ITPub博客

首页 > 应用开发 > Python > python chrome Selenium模拟手机浏览器

python chrome Selenium模拟手机浏览器

原创 Python 作者:testingbang 时间:2019-08-01 23:00:15 0 删除 编辑

环境

安装chrome,F12后有个模拟手机浏览器的功能,如果找不到就自己google下啊

python+chrome+Selenium模拟手机浏览器

下载chromedriver.exe,并放到python的根目录下

实现代码

不废话,直接码起来~

#引入必要的包

from selenium import webdriver

from time import sleep

#设置

mobileEmulation = {'deviceName': 'Apple iPhone 6 Plus'}

options = webdriver.ChromeOptions()

options.add_experimental_option('mobileEmulation', mobileEmulation)

#启动driver

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

#访问百度wap页

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

sleep(3)

driver.quit()


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69942496/viewspace-2652528/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
公众号:测试帮日记 QQ群:229390571

注册时间:2019-07-27

  • 博文量
    274
  • 访问量
    338246