Open website in web browser when url has been copied into Clipboard with Python for Windows Systems

import time
import webbrowser
import win32clipboard
from urllib.parse import urlparse

print("##########################")
print("# Listening to clipboard #")
print("##########################")

prevData = ''

# Clear clipboard
try:
	win32clipboard.OpenClipboard()
	win32clipboard.EmptyClipboard()
	win32clipboard.CloseClipboard()
except:
	print('Error!')

# Listen to clipboard paste event
while(True):

	win32clipboard.OpenClipboard()

	try:
		data = win32clipboard.GetClipboardData()
	except:
		data = ''

	win32clipboard.CloseClipboard()
	
	if(data):
		print("[DEBUG] {data} " + data)
		print("[DEBUG] {prevData} " + prevData)

	if(prevData != data):
		prevData = data
		parsedUrl = urlparse(data)
		
		# check regex
		if(parsedUrl.scheme and parsedUrl.netloc):
			print("[OPEN URL] " + data)
			
			webbrowser.open(data, new=2)

			win32clipboard.OpenClipboard()
			win32clipboard.EmptyClipboard()
			win32clipboard.CloseClipboard()

	time.sleep(1)