我想学会如下代码这些东西,应该学习哪些具体知识
朋友把源码给我 我都迷糊,求大佬帮忙解答解答,还有一个文件的源码@file: SetCookies.py
@description: 主动设置Cookie
"""
from PyQt5.QtCore import QDateTime, Qt, QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineProfile, QWebEngineView, QWebEnginePage
from PyQt5.QtWidgets import QApplication
from PyQt5.QtNetwork import QNetworkCookie
from PyQt5 import QtGui
class MyWebEngineView(QWebEngineView):
def __init__(self, *args, **kwargs):
super(MyWebEngineView, self).__init__(*args, **kwargs)
# global
# self.cookieStore = QWebEngineProfile.defaultProfile().cookieStore()
def setup(self,username,password,role_index):
print(role_index)
import utils
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
self.m_89 = m_89
self.jsessionid = jsessionid
role_id = role_id_list
print(m_89,jsessionid,role_id)
client_html = utils.login_role(m_89, jsessionid, role_id)
role_utils = utils.setup_role_utils(m_89, jsessionid)
validateParam, current_room = utils.get_login_info_from_client_html(client_html)
if True:
storage = "./miu_profile/" + str(role_id)
profile = QWebEngineProfile(storage, self)
page = QWebEnginePage(profile, self)
# self.setPage(page)
self.setPage(page)
# current
self.cookieStore = self.page().profile().cookieStore()
# self.cookieStore = QWebEngineProfile.defaultProfile().cookieStore()
# self.initCookies()
self.cookies = [{
"domain": "51wan.olplay.com:89",
"hostOnly": True,
"httpOnly": False,
"name": "JSESSIONID",
"value": jsessionid,
"path": "/",
"secure": False,
}, {
"domain": "51wan.olplay.com:89",
"hostOnly": True,
"httpOnly": False,
"name": "m",
"value": m_89,
"path": "/",
"secure": False,
}]
for cookie in self.cookies:
qcookie = QNetworkCookie()
qcookie.setName(cookie.get('name', '').encode())
print(cookie.get('value', ''))
qcookie.setValue(cookie.get('value', '').encode())
qcookie.setDomain(cookie.get('domain', ''))
qcookie.setPath(cookie.get('path', ''))
qcookie.setExpirationDate(
QDateTime.fromString(str(cookie.get('expirationDate', 0)),
Qt.ISODate))
qcookie.setHttpOnly(cookie.get('httpOnly', False))
qcookie.setSecure(cookie.get('secure', False))
# 注意可以设置具体的url
self.cookieStore.setCookie(qcookie, QUrl())
self.loadProgress.connect(self.onLoadProgress)
self.load(QUrl('http://51wan.olplay.com:89/'))
def onLoadProgress(self, progress):
print(progress)
if progress == 80:
# print(self.m_89,self.jsessionid)
print(self.cookieStore)
# self.page().runJavaScript('alert(document.cookie);')
# self.page().runJavaScript('alert(document);')
# self.webEngineView.page().setDevToolsPage(self.inspector.page())
# self.page().setDevToolsPage(self.page())
# self.page().runJavaScript('alert(document.cookie);')
# self.page().runJavaScript('document.write(document.cookie);')
if True:
if False:
DEBUG_PORT = '5588'
DEBUG_URL = 'http://127.0.0.1:%s' % DEBUG_PORT
import os
os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = DEBUG_PORT
self.inspector = QWebEngineView()
self.inspector.setMyWebEngineViewTitle('Web Inspector')
self.inspector.load(QUrl(DEBUG_URL))
# self.page().loadFinished.connect(self.handleHtmlLoaded)
self.page().setDevToolsPage(self.inspector.page())
self.inspector.show()
# document.getElementsByTagName('frame').contentMyWebEngineView.document.getElementById('gameDoc')
if True:
# self.page().runJavaScript("console.log(document.querySelector('#gameDoc'))")
self.page().runJavaScript("""
let count = 0;
let timer = setInterval(()=>{
let dcmt = window.top.document.querySelector("frame").contentDocument
dcmt.querySelector('#gameDoc')
dcmt.body.style.zoom = '80%'
var inputBar = dcmt.querySelector('.inputBar')
inputBar.style.marginLeft = '-800px'
inputBar.style.marginTop = '50px'
var inputBar= dcmt.querySelector('#sd_meet_gen')
inputBar.style.marginLeft = '-600px'
inputBar.style.marginTop = '50px'
var inputBar = dcmt.querySelector('#opt_meet_gen')
inputBar.style.marginLeft = '-600px'
inputBar.style.marginTop = '50px'
if(count >5){
clearInterval(timer)
}
count += 1;
//dcmt.querySelector('#chatReader').remove()
//dcmt.querySelector('#chatMyReader').remove()
//dcmt.querySelector('#helpBar').remove()
},3000)
""")
# if progress == 100:
# # 测试获取cookie
# print('progress 100')
# self.page().runJavaScript('alert(document.cookie);')
class MyWebEngineView1(QWebEngineView):
def __init__(self, *args, **kwargs):
super(MyWebEngineView1, self).__init__(*args, **kwargs)
# global
# self.cookieStore = QWebEngineProfile.defaultProfile().cookieStore()
def setup(self, m_89, jsessionid, role_id):
# # print(role_index)
import utils
#
# m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
#
# self.m_89 = m_89
# self.jsessionid = jsessionid
#
# role_id = role_id_list
# print(m_89, jsessionid, role_id)
client_html = utils.login_role(m_89, jsessionid, role_id)
role_utils = utils.setup_role_utils(m_89, jsessionid)
validateParam, current_room = utils.get_login_info_from_client_html(client_html)
if True:
storage = "./miu_profile/" + str(role_id)
profile = QWebEngineProfile(storage, self)
page = QWebEnginePage(profile, self)
# self.setPage(page)
self.setPage(page)
# current
self.cookieStore = self.page().profile().cookieStore()
# self.cookieStore = QWebEngineProfile.defaultProfile().cookieStore()
# self.initCookies()
self.cookies = [{
"domain": "51wan.olplay.com:89",
"hostOnly": True,
"httpOnly": False,
"name": "JSESSIONID",
"value": jsessionid,
"path": "/",
"secure": False,
}, {
"domain": "51wan.olplay.com:89",
"hostOnly": True,
"httpOnly": False,
"name": "m",
"value": m_89,
"path": "/",
"secure": False,
}]
for cookie in self.cookies:
qcookie = QNetworkCookie()
qcookie.setName(cookie.get('name', '').encode())
print(cookie.get('value', ''))
qcookie.setValue(cookie.get('value', '').encode())
qcookie.setDomain(cookie.get('domain', ''))
qcookie.setPath(cookie.get('path', ''))
qcookie.setExpirationDate(
QDateTime.fromString(str(cookie.get('expirationDate', 0)),
Qt.ISODate))
qcookie.setHttpOnly(cookie.get('httpOnly', False))
qcookie.setSecure(cookie.get('secure', False))
# 注意可以设置具体的url
self.cookieStore.setCookie(qcookie, QUrl())
self.loadProgress.connect(self.onLoadProgress)
self.load(QUrl('http://51wan.olplay.com:89/'))
def onLoadProgress(self, progress):
print(progress)
if progress == 80:
# print(self.m_89,self.jsessionid)
print(self.cookieStore)
# self.page().runJavaScript('alert(document.cookie);')
# self.page().runJavaScript('alert(document);')
# self.webEngineView.page().setDevToolsPage(self.inspector.page())
# self.page().setDevToolsPage(self.page())
# self.page().runJavaScript('alert(document.cookie);')
# self.page().runJavaScript('document.write(document.cookie);')
if True:
if False:
DEBUG_PORT = '5588'
DEBUG_URL = 'http://127.0.0.1:%s' % DEBUG_PORT
import os
os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = DEBUG_PORT
self.inspector = QWebEngineView()
self.inspector.setMyWebEngineViewTitle('Web Inspector')
self.inspector.load(QUrl(DEBUG_URL))
# self.page().loadFinished.connect(self.handleHtmlLoaded)
self.page().setDevToolsPage(self.inspector.page())
self.inspector.show()
# document.getElementsByTagName('frame').contentMyWebEngineView.document.getElementById('gameDoc')
if True:
# self.page().runJavaScript("console.log(document.querySelector('#gameDoc'))")
self.page().runJavaScript("""
let count = 0;
let timer = setInterval(()=>{
let dcmt = window.top.document.querySelector("frame").contentDocument
dcmt.querySelector('#gameDoc')
dcmt.body.style.zoom = '70%'
var inputBar = dcmt.querySelector('.inputBar')
inputBar.style.marginLeft = '-800px'
inputBar.style.marginTop = '50px'
var inputBar= dcmt.querySelector('#sd_meet_gen')
inputBar.style.marginLeft = '-600px'
inputBar.style.marginTop = '50px'
var inputBar = dcmt.querySelector('#opt_meet_gen')
inputBar.style.marginLeft = '-600px'
inputBar.style.marginTop = '50px'
if(count >5){
clearInterval(timer)
}
count += 1;
//dcmt.querySelector('#chatReader').remove()
//dcmt.querySelector('#chatMyReader').remove()
//dcmt.querySelector('#helpBar').remove()
},3000)
""")
# if progress == 100:
# # 测试获取cookie
# print('progress 100')
# self.page().runJavaScript('alert(document.cookie);')
if __name__ == '__main__':
import cgitb
import sys
cgitb.enable(format='text')
app = QApplication(sys.argv)
w = MyWebEngineView()
w.show()
sys.exit(app.exec_())
import time
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
import sys
from miu_browser import MyWebEngineView
from PyQt5.QtCore import QRunnable, Qt, QThreadPool
from PyQt5.QtWidgets import (
QApplication,
QLabel,
QMainWindow,
QPushButton,
QVBoxLayout,
QWidget,
)
import logging
# 1. Subclass QRunnable
class Runnable(QRunnable):
def __init__(self,role_utils):
super().__init__()
self.role_utils = role_utils
def run(self):
# Your long-running task goes here ...
items = self.role_utils.get_items()
print('QRunnable run')
# for item in items:
# print(item)
for item in items:
str_desc = item
item_name = item
item_id = item
item_count = item
# print(item)
if 'arm.armor' in str_desc and 'uncommon' in str_desc:
print(item)
if False:
self.role_utils.send_command('/foo fenjie {}'.format(item_id))
time.sleep(7)
pass
class MainWindow(QWidget):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
if False:
layout = QGridLayout()
# Add widgets to the layout
layout.addWidget(QPushButton("Button at (0, 0)"), 0, 0)
layout.addWidget(QPushButton("Button at (0, 1)"), 0, 1)
layout.addWidget(QPushButton("Button Spans two Cols"), 1, 0, 1, 2)
# Set the layout on the application's window
self.setLayout(layout)
self.show()
def setup(self, username, password):
self.setWindowTitle('miu')
import utils
from miu_browser import MyWebEngineView1
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
role_info_list = []
self.browser = MyWebEngineView1()
self.browser.setup(m_89, jsessionid, role_id_list)
role_info_list.append({
'm_89': m_89,
'jsessionid': jsessionid,
'role_id': role_id_list
})
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
self.browser1 = MyWebEngineView1()
self.browser1.setup(m_89, jsessionid, role_id_list)
role_info_list.append({
'm_89': m_89,
'jsessionid': jsessionid,
'role_id': role_id_list
})
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
self.browser2 = MyWebEngineView1()
self.browser2.setup(m_89, jsessionid, role_id_list)
role_info_list.append({
'm_89': m_89,
'jsessionid': jsessionid,
'role_id': role_id_list
})
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
self.browser3 = MyWebEngineView1()
self.browser3.setup(m_89, jsessionid, role_id_list)
role_info_list.append({
'm_89': m_89,
'jsessionid': jsessionid,
'role_id': role_id_list
})
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
self.browser4 = MyWebEngineView1()
self.browser4.setup(m_89, jsessionid, role_id_list)
role_info_list.append({
'm_89': m_89,
'jsessionid': jsessionid,
'role_id': role_id_list
})
layout = QGridLayout()
layout.addWidget(self.browser, 0, 0)
layout.addWidget(self.browser1, 0, 1)
layout.addWidget(self.browser2, 0, 2)
layout.addWidget(self.browser3, 1, 0)
layout.addWidget(self.browser4, 1, 1)
self.setLayout(layout)
# setup buttons
if True:
button_grid = QGridLayout()
layout.addLayout(button_grid, 1, 2)
self.teamButton = QPushButton('组队(会先退出当前队伍')
button_grid.addWidget(self.teamButton, 0, 0)
self.followButton = QPushButton('跟随')
button_grid.addWidget(self.followButton, 1, 0)
self.repairButton = QPushButton('修理全部')
button_grid.addWidget(self.repairButton, 2, 0)
# self. = QLineEdit()
# button_grid.addWidget(self.clearBagButton, 3, 0)
self.clearBagButton = QPushButton('丢弃绿图/溶xx石/')
button_grid.addWidget(self.clearBagButton, 4, 0)
self.learnButton = QPushButton('学习分解(需要先走到哨所')
button_grid.addWidget(self.learnButton, 5, 0)
# self.learnButton = QPushButton('学习分解(需要先走到哨所')
# button_grid.addWidget(self.learnButton, 6, 0)
self.disenchantButton = QPushButton('分解所有绿装')
button_grid.addWidget(self.disenchantButton, 7, 0)
# 分解添加到快捷栏
# /putcut skill skill.output.FenJie 11
# /foo fenjie 109068010
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
SLEEP_INTERVAL = 1
def teamButtonClicked():
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
role_utils = utils.setup_role_utils(m0, j0)
SLEEP_INTERVAL = 0.3
role_utils = utils.setup_role_utils(m0, j0)
role_utils.send_command("/foo rank tui {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m1, j1)
role_utils.send_command("/foo rank tui {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m2, j2)
role_utils.send_command("/foo rank tui {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m3, j3)
role_utils.send_command("/foo rank tui {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m4, j4)
role_utils.send_command("/foo rank tui {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m0, j0)
role_utils.send_command("/foo rank add {}".format(i1))
time.sleep(SLEEP_INTERVAL)
role_utils.send_command("/foo rank add {}".format(i2))
time.sleep(SLEEP_INTERVAL)
role_utils.send_command("/foo rank add {}".format(i3))
time.sleep(SLEEP_INTERVAL)
role_utils.send_command("/foo rank add {}".format(i4))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m1, j1)
role_utils.send_command("/foo rank agree {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m2, j2)
role_utils.send_command("/foo rank agree {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m3, j3)
role_utils.send_command("/foo rank agree {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m4, j4)
role_utils.send_command("/foo rank agree {}".format(i0))
time.sleep(SLEEP_INTERVAL)
def follow():
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
SLEEP_INTERVAL = 1
role_utils = utils.setup_role_utils(m1, j1)
role_utils.send_command("/follow {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m2, j2)
role_utils.send_command("/follow {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m3, j3)
role_utils.send_command("/follow {}".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m4, j4)
role_utils.send_command("/follow {}".format(i0))
time.sleep(SLEEP_INTERVAL)
def repair():
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
SLEEP_INTERVAL = 1
role_utils = utils.setup_role_utils(m0, j0)
role_utils.send_command("/xiuli all".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m1, j1)
role_utils.send_command("/xiuli all".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m2, j2)
role_utils.send_command("/xiuli all".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m3, j3)
role_utils.send_command("/xiuli all".format(i0))
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m4, j4)
role_utils.send_command("/xiuli all".format(i0))
time.sleep(SLEEP_INTERVAL)
def clearBag():
role_utils = utils.setup_role_utils(m0, j0)
items = role_utils.get_items()
for item in items:
print(item)
# if item in []:
# role_utils.send_command('/drop {} {}'.format(item,item))
role_utils_list = [utils.setup_role_utils(m0, j0),
utils.setup_role_utils(m1, j1),
utils.setup_role_utils(m2, j2),
utils.setup_role_utils(m3, j3),
utils.setup_role_utils(m4, j4)
]
for role_utils in role_utils_list:
items = role_utils.get_items()
time.sleep(1)
for item in items:
# print(item)
str_desc = item
item_name = item
item_id = item
item_count = item
if item_name.startswith('魔石图') and not item_name.endswith('晶石') and not item_name.endswith(
'魔石'):
print(item_name, str_desc)
role_utils.send_command('/drop {} {}'.format(item_id, item_count))
time.sleep(1)
if item_name.startswith('设计图') and 'lv' in str_desc.lower():
print(item_name, str_desc)
role_utils.send_command('/drop {} {}'.format(item_id, item_count))
time.sleep(1)
if item_name.startswith('缝纫图') and 'lv' in str_desc.lower():
print(item_name, str_desc)
role_utils.send_command('/drop {} {}'.format(item_id, item_count))
time.sleep(1)
if '溶' in item_name and item_name.endswith('石'):
print(item_name, str_desc)
role_utils.send_command('/drop {} {}'.format(item_id, item_count))
time.sleep(1)
# if (item_name.startswith('缝纫图')
# or item_name.startswith('魔石图')
# or item_name.startswith('设计图')
# ):
# if (item_name.startswith('缝纫图')
# or item_name.startswith('魔石图')
# or item_name.startswith('设计图')
# ) and ('uncommon' in str_desc.lower or 'lv' in str_desc.lower):
# role_utils.send_command('/drop {} {}'.format(item_id, item_count))
# time.sleep(1)
def learn_disenchant():
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
SLEEP_INTERVAL = 1
role_utils = utils.setup_role_utils(m0, j0)
role_utils.send_command("/talk 1 z_2")
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m1, j1)
role_utils.send_command("/talk 1 z_2")
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m2, j2)
role_utils.send_command("/talk 1 z_2")
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m3, j3)
role_utils.send_command("/talk 1 z_2")
time.sleep(SLEEP_INTERVAL)
role_utils = utils.setup_role_utils(m4, j4)
role_utils.send_command("/talk 1 z_2")
def disenchant():
r0 = role_info_list
r1 = role_info_list
r2 = role_info_list
r3 = role_info_list
r4 = role_info_list
m0, j0, i0 = r0.values()
m1, j1, i1 = r1.values()
m2, j2, i2 = r2.values()
m3, j3, i3 = r3.values()
m4, j4, i4 = r4.values()
SLEEP_INTERVAL = 1
print('disenchant')
role_utils = utils.setup_role_utils(m0, j0)
role_utils_list = [utils.setup_role_utils(m0, j0),
utils.setup_role_utils(m1, j1),
utils.setup_role_utils(m2, j2),
utils.setup_role_utils(m3, j3),
utils.setup_role_utils(m4, j4)
]
pool = QThreadPool.globalInstance()
for role_utils in role_utils_list:
# threadCount = QThreadPool.globalInstance().maxThreadCount()
runnable = Runnable(role_utils)
pool.start(runnable)
continue
items = role_utils.get_items()
time.sleep(1)
for item in items:
str_desc = item
item_name = item
item_id = item
item_count = item
# print(item)
if 'arm.armor' in str_desc and 'uncommon' in str_desc:
print(item)
# role_utils.send_command('/')
# if item.startswith('缝纫图'):
#
# time.sleep(SLEEP_INTERVAL)
# role_utils = utils.setup_role_utils(m1, j1)
#
# time.sleep(SLEEP_INTERVAL)
# role_utils = utils.setup_role_utils(m2, j2)
#
# time.sleep(SLEEP_INTERVAL)
# role_utils = utils.setup_role_utils(m3, j3)
#
# time.sleep(SLEEP_INTERVAL)
# role_utils = utils.setup_role_utils(m4, j4)
self.teamButton.clicked.connect(teamButtonClicked)
self.followButton.clicked.connect(follow)
self.repairButton.clicked.connect(repair)
self.clearBagButton.clicked.connect(clearBag)
self.learnButton.clicked.connect(learn_disenchant)
self.disenchantButton.clicked.connect(disenchant)
print(role_info_list)
# self.setCentralWidget(self.browser)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
g_u = None
g_p = None
g_window = None
class LoginWin(QMainWindow):
def __init__(self):
super(LoginWin, self).__init__()
self.setWindowTitle("My App")
layout = QGridLayout()
uInput = QLineEdit('ceshizhanghao000')
pInput = QLineEdit('ceshizhanghao')
loginButton = QPushButton('多开')
layout.addWidget(uInput, 0, 0)
layout.addWidget(pInput, 1, 0)
layout.addWidget(loginButton, 2, 0)
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
def login():
g_u = uInput.text()
g_p = pInput.text()
self.close()
if True:
g_window.setup(g_u, g_p)
loginButton.clicked.connect(login)
lw = LoginWin()
lw.show()
g_window = MainWindow()
app.exec_()
halemorning 发表于 2023-2-28 18:29
import time
from PyQt5.QtCore import *
PYQT5 啊百度就好了这是一个专门研究GUI的模块
传统TK 大家都嫌它的界面太丑 所以就有了更先进的模块(但同时 也更加复杂) m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
File "F:\pythonProject3\MiuMultiBrowser_launch1.py", line 460, in login
g_window.setup(g_u, g_p)
File "F:\pythonProject3\MiuMultiBrowser_launch1.py", line 67, in setup
m_89, jsessionid, role_id_list = utils.get_m_jsessionid_id_list(username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'utils' has no attribute 'get_m_jsessionid_id_list'
这个错误不知道怎么解决了 要学习这段代码,需要掌握以下知识:
PyQt5 库:PyQt5 是 Python 语言的一个 GUI 框架,可用于创建 Windows、MacOS 和 Linux 上的桌面应用程序。它提供了很多控件和功能,可以方便地创建用户界面和处理用户交互。
QWebEngineView 控件:QWebEngineView 是 PyQt5 中的一个控件,用于显示 Web 页面。它基于 Chromium 引擎,支持现代 Web 技术,如 HTML5、CSS3 和 JavaScript。
QWebEngineProfile 和 QWebEnginePage 类:QWebEngineProfile 和 QWebEnginePage 是 QWebEngineView 的两个重要组件。QWebEngineProfile 用于管理 WebEngine 的配置和数据,如 Cookie、缓存、代理等等。QWebEnginePage 用于显示 Web 页面,并提供了很多操作功能,如加载页面、执行 JavaScript、截图等等。
Cookie:Cookie 是一种 Web 技术,用于在客户端保存用户的状态信息。在这段代码中,通过设置 Cookie 来模拟用户登录网站。可以使用 QNetworkCookie 类来创建和管理 Cookie。
Python 的基础知识:这段代码中还涉及到 Python 的一些基础知识,如类的继承、列表和字典的使用等等。
Web 技术:这段代码中涉及到的网站登录和 Cookie 设置是 Web 技术的一部分,需要了解相关的知识。
建议先学习 Python 的基础知识和 Web 技术,然后再学习 PyQt5 和 QWebEngineView 控件的使用。可以参考一些 Python、Web 技术、PyQt5 和 QWebEngineView 的教程、书籍和在线课程进行学习。 不二猫猫 发表于 2023-3-14 23:04
要学习这段代码,需要掌握以下知识:
PyQt5 库:PyQt5 是 Python 语言的一个 GUI 框架,可用于创建 Wind ...
谢谢大佬详细的讲解,接下来我会根据路线去学习
页:
[1]