模拟手机浏览器
selenium
from selenium import webdriver mobile_emulation = {"deviceName": "Google Nexus 5"} chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) browser = webdriver.Chrome(chrome_options=chrome_options) browser.get('http://www.baidu.com') browser.quit()
splinter
from selenium import webdriver from splinter import Browser mobile_emulation = {"deviceName": "Google Nexus 5"} chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) browser = Browser('chrome', options=chrome_options) browser.visit('http://www.baidu.com')
browser.quit()