成都创新互联网站制作重庆分公司

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

环境

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

10年积累的成都网站设计、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先建设网站后付款的网站建设流程,更有朝天免费网站建设让你可以放心的选择与我们合作。

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()

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


分享名称:python+chrome+Selenium模拟手机浏览器
分享URL:http://cxhlcq.com/article/ggsjih.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部