RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
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://sczitong.cn/article/ggsjih.html