import sys
from PyQt5.QtCore import QUrl, QSize, Qt,,QCoreApplication
from PyQt5.QtWidgets import QApplication, QMainWindow, QLineEdit, QDesktopWidget, QAction, QToolBar, QTabWidget, \
QWidget, QHBoxLayout, QPushButton
from PyQt5.QtGui import QIcon
from PyQt5.QtWebEngineWidgets import QWebEngineView,QWebEnginePage
from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInterceptor
class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor):
def __init__(self, parent=None):
super().__init__(parent)
def interceptRequest(self, info):
url = info.requestUrl()
# print(url.filename())
# exit()
if url.fileName() == "luckyMonster":
# print(url.filename())
print(str(info.requestUrl()))
#print(info.requestUrl(), info.requestMethod(), info.resourceType(), info.firstPartyUrl())
#print(info.requestUrl(),info.requestMethod(),info.resourceType(),info.firstPartyUrl())
# luckyMonster
class WebView(QWebEngineView):
def __init__(self, mainWin, parent=None):
super().__init__(mainWin)
self.mainWin = mainWin
# 重写createwindow()
def createWindow(self, QWebEnginePage_WebWindowType):
new_webview = WebView(self.mainWin)
self.mainWin.create_tab(new_webview)
return new_webview
class Browser(QMainWindow):
def __init__(self, mainWin, webview=None):
super().__init__(mainWin)
self.showFullScreen()
self.mainWin = mainWin
self.webview = webview
self.initUI()
def initUI(self):
# self.setWindowFlags(Qt.FramelessWindowHint) # 去掉标题栏的代码
# 设置窗口标题
self.set