Skip to content

Instantly share code, notes, and snippets.

@vijaypurohit
Created December 15, 2017 16:06
Show Gist options
  • Save vijaypurohit/143582c0b225d74d9e7367708524e724 to your computer and use it in GitHub Desktop.
Save vijaypurohit/143582c0b225d74d9e7367708524e724 to your computer and use it in GitHub Desktop.
This code is used to open link in incognito mode of browser and then close. this is repeat for certain amount of time
import time
import webbrowser
import os
'''give value you want to open url'''
a = 30
'''enter the url is here'''
url = 'https://stackoverflow.com/questions/37769148/how-to-open-chrome-in-incognito-mode-from-python'
'''this path of chrome is defult change if your chrome path other '''
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s --incognito'
'''here is while loop'''
while a > 0:
webbrowser.get(chrome_path).open_new(url) #for open url
print('browser is opened')
time.sleep(10) #time sleep is also in second
os.system("taskkill /f /im chrome.exe")
a = a-1
print(a,'time is left')
'''this program work for www, http and https'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment