九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
python 模擬瀏覽器
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
class cookieJar(QtNetwork.QNetworkCookieJar):
    def __init__(self, cookiesKey, parent=None):
        super(cookieJar, self).__init__(parent)
        self.mainWindow = parent
        self.cookiesKey = cookiesKey
        cookiesValue    = self.mainWindow.settings.value(self.cookiesKey)      
        if cookiesValue:
            cookiesList = QtNetwork.QNetworkCookie.parseCookies(cookiesValue)
            self.setAllCookies(cookiesList)
   # def setCookiesFromUrl (self, cookieList, url):
    #    cookiesValue = self.mainWindow.settings.value(self.cookiesKey)
     #   cookiesArray = cookiesValue if cookiesValue else QtCore.QByteArray()
      #  for cookie in cookieList:
       #     cookiesArray.append(cookie.toRawForm() + "\n")
        #self.mainWindow.settings.setValue(self.cookiesKey, cookiesArray)
        #return super(cookieJar, self).setCookiesFromUrl(cookieList, url)
    def deleteCookie(self,cookieList):
    cookie = []
    self.mainWindow.settings.value(cookie)
class webView(QtWebKit.QWebView):
    def __init__(self, cookiesKey, url, parent=None):
        super(webView, self).__init__(parent)
        self.cookieJar = cookieJar(cookiesKey, parent)
        self.page().networkAccessManager().setCookieJar(self.cookieJar)
class myWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(myWindow, self).__init__(parent)
        self.cookiesKey = "cookies"
        self.centralwidget = QtGui.QWidget(self)
        self.tabWidget = QtGui.QTabWidget(self.centralwidget)
        self.tabWidget.setTabsClosable(True)
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.addWidget(self.tabWidget)
        self.actionTabAdd = QtGui.QAction(self)
        self.actionTabAdd.setText("Add Tab")
        self.actionTabAdd.triggered.connect(self.on_actionTabAdd_triggered)
        self.lineEdit = QtGui.QLineEdit(self)
        self.lineEdit.setText("http://www.example.com")
        self.toolBar = QtGui.QToolBar(self)
        self.toolBar.addAction(self.actionTabAdd)
        self.toolBar.addWidget(self.lineEdit)
        self.addToolBar(QtCore.Qt.ToolBarArea(QtCore.Qt.TopToolBarArea), self.toolBar)
        self.setCentralWidget(self.tabWidget)
        self.settings = QtCore.QSettings()
    @QtCore.pyqtSlot()
    def on_actionShowCookies_triggered(self):
        webView = self.tabWidget.currentWidget()
        listCookies = webView.page().networkAccessManager().cookieJar().allCookies()
        for cookie in  listCookies:
            print cookie.toRawForm()
    @QtCore.pyqtSlot()
    def on_actionTabAdd_triggered(self):
        url = self.lineEdit.text()
        self.addNewTab(url if url else 'about:blank')
    def addNewTab(self, url):
        tabName = u"Tab {0}".format(str(self.tabWidget.count()))
        tabWidget= webView(self.cookiesKey, url, self)
        tabWidget.loadFinished.connect(self.on_tabWidget_loadFinished)
        tabWidget.load(QtCore.QUrl(url))
        tabIndex = self.tabWidget.addTab(tabWidget, tabName)
        self.tabWidget.setCurrentIndex(tabIndex)
    @QtCore.pyqtSlot()
    def on_tabWidget_loadFinished(self):
        cookies2 = self.settings.value(self.cookiesKey)
     
     
if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName('myWindow')
    main = myWindow()
    main.resize(666, 333)
    main.show()
    sys.exit(app.exec_())
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
如何在PyQt或PySide中更改最小化事件行為?
用 eric6 與 PyQt5 實現(xiàn)python的極速GUI編程
PyQt4 教程(5)
Python實現(xiàn)可以語音聊天的桌面寵物程序
PyQt4 信號和槽詳解
PyQt5快速入門(六)PyQt5 GUI界面設(shè)計
更多類似文章 >>
生活服務(wù)
熱點新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服