Just add the UA for your smartphone to the options argument.
** ▼ For iphone safari **
Options to add
options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1')
** ▼ Code example **
python
#-*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True
#Specify the screen size to capture
options.add_argument('--window-size=412,732')
####driver.set_window_size(600,1000)
#Specify UA
options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1')
driver = webdriver.Chrome(options=options)
#Specify URL
driver.get("https://www.google.co.jp/")
#Specify the capture file name and extension
driver.save_screenshot('googletop-sp.png')
driver.quit()
Android(Google WebLight Proxy)
Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19
Available for mobile and mobile phone.
iphone(Safari 13)
Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1
Recommended Posts