how to open chrome in incognito mode from Python

3z33etm picture 3z33etm · Jun 12, 2016 · Viewed 16.8k times · Source

This works, in powershell:

Start-Process chrome.exe -ArgumentList @( '-incognito', 'www.foo.com' )

How can this be achieved from Python?

Answer

Vivek Kumar picture Vivek Kumar · Mar 20, 2017

Python Script to open incognito mode in chrome using webbrowser

import webbrowser
url = 'www.google.com'
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s --incognito'
webbrowser.get(chrome_path).open_new(url)