webdriver打开头条手机网页失败,求教
python吧
全部回复
仅看楼主
level 3
带泪的鱼6 楼主
toutiao_phone = 'https://m.toutiao.com'toutiao_pc = 'https://www.toutiao.com/'
mobileEmulation = {'deviceName': 'Apple iPhone 4'}mobile_emulation = { "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 }, "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" }if __name__ == "__main__":print u'T 1.0 自动抓取头条的页面数据'
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation', mobile_emulation)
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)driver.set_window_position(1000,0)driver.set_window_size(320,640)# driver.get('http://m.baidu.com')driver.get(toutiao_phone)
time.sleep(15)driver.close()
2018年05月14日 12点05分 1
1