安裝chrome,F12後有個模擬手機瀏覽器的功能,若是找不到就本身google下啊python
下載chromedriver.exe,並放到python的根目錄下web
不廢話,直接碼起來~chrome
#引入必要的包瀏覽器
from selenium import webdriver微信
from time import sleepide
#設置ui
mobileEmulation = {'deviceName': 'Apple iPhone 6 Plus'}google
options = webdriver.ChromeOptions()spa
options.add_experimental_option('mobileEmulation', mobileEmulation)orm
#啓動driver
driver=webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)
#訪問百度wap頁
driver.get('http://m.baidu.com')
sleep(3)
driver.quit()