0
산업용 바코드 스캐너가 있습니다.파이썬으로 웹 브라우저에서 QRCode 열기
URI가 포함 된 QRCode를 스캔하려고하며이 URI를 시스템의 기본 브라우저에서 자동으로 열어야합니다.
나는 다음과 같은 코드가 있습니다
# -*- coding: utf-8 -*-
import pyHook
import pythoncom
import re
import webbrowser
endDomains = ".de|.com|.net|.org|.edu|.gov|.mil|.aero|.asia|.biz|.cat|.coop|.info|.int|.jobs|.mobi|.museum|.name|.post|.pro|.tel|.travel".split("|")
chars = ""
def pressed_chars(event):
global chars
if event.Ascii:
char = chr(event.Ascii)
if event.Ascii == 3:
quit()
else:
chars += char
try:
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[[email protected]&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', chars)
print(urls)
except:
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[[email protected]&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', chars)
print(urls)
if len(urls) > 0:
for url in urls:
for i in endDomains:
if i in url:
webbrowser.open_new_tab(url)
chars = ""
break
proc = pyHook.HookManager()
proc.KeyDown = pressed_chars
proc.HookKeyboard()
pythoncom.PumpMessages()
을하지만 브라우저를 열지 않습니다. 아무도 도와 줄 수 있습니까?
운영 체제는 Python 2.7 + Pyhook이 설치된 Windows 10입니다.