Python PyQt4.QtCore 模块,QUrl() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtCore.QUrl()

项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def createRequest(self, op, request, device=None):
        """ Reimplemented to enable adblock/url-block """
        if op!=self.GetOperation or request.url().scheme()=='file':
            return QtNetwork.QNetworkAccessManager.createRequest(self, op, request, device)
        url = unicode(request.url().toString())
        block = False
        # Font blocking capability
        if block_fonts:
            if '.ttf' in url or '.woff' in url:
              block = True
        # AdBlocking Feature
        if enable_adblock:
            for ad in ad_strings:
                if ad in url:
                    block = True
                    break

        if block:
#            print("Blocked: "+url)
            return QtNetwork.QNetworkAccessManager.createRequest(self, op, QtNetwork.QNetworkRequest(QtCore.QUrl()), device)

        reply = QtNetwork.QNetworkAccessManager.createRequest(self, op, request, device)
        #reply.metaDataChanged.connect(self.gotMetadata)
        return reply
项目:PyIntroduction    作者:tody411    | 项目源码 | 文件源码
def mainPyQt5():
    # ?????????import
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWebEngineWidgets import QWebEngineView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebEngineView???Web?????
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_())
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def startDownload(self, req):
        loop = QtCore.QEventLoop()
        QtCore.QTimer.singleShot(5000, loop.quit)
        self.reply = self.networkmanager.get(req)
        self.reply.metaDataChanged.connect(loop.quit)
        loop.exec_()
        #wait(1000)
        if self.reply.hasRawHeader('Location'):
            URL = QtCore.QUrl.fromUserInput(unicode(self.reply.rawHeader('Location')))
            self.reply.abort()
            req = QtNetwork.QNetworkRequest(URL)
            req.setRawHeader('User-Agent', self.useragent)
            self.startDownload(req)
            return
        print str(self.reply.url().toString().toUtf8())
        if self.reply.isFinished():
            self.dataReceived()
            self.downloadStopped()
            return
        self.reply.finished.connect(self.downloadStopped)
        #self.reply.readyRead.connect(self.dataReceived)
        self.reply.error.connect(self.downloadError)
项目:PyIntroduction    作者:tody411    | 项目源码 | 文件源码
def mainPyQt4Simple():
    # ?????????import
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView

    url = 'https://github.com/tody411/PyIntroduction'

    app = QApplication(sys.argv)

    # QWebView???Web?????
    browser = QWebView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_())

## PyQt4??Web???????(Youtube?).
项目:batch_gps_importer    作者:wondie    | 项目源码 | 文件源码
def setupUi(self, StaticHelp):
        StaticHelp.setObjectName(_fromUtf8("StaticHelp"))
        StaticHelp.resize(698, 595)
        self.verticalLayout = QtGui.QVBoxLayout(StaticHelp)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.help_view = QtWebKit.QWebView(StaticHelp)
        self.help_view.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
        self.help_view.setObjectName(_fromUtf8("help_view"))
        self.verticalLayout.addWidget(self.help_view)
        self.buttonBox = QtGui.QDialogButtonBox(StaticHelp)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.verticalLayout.addWidget(self.buttonBox)

        self.retranslateUi(StaticHelp)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), StaticHelp.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), StaticHelp.reject)
        QtCore.QMetaObject.connectSlotsByName(StaticHelp)
项目:batch_gps_importer    作者:wondie    | 项目源码 | 文件源码
def load_html_from_text(self, text):
        """
        Loads html file by constructing the path using a clicked label.
        :param text: The label text
        :type text: String
        """
        self.dynamic_help_box.setHtml('')
        anchor_text = text.replace(' ', '_').lower().replace('-', '_')
        file_name = 'help'
        help_path = u'{}/{}.html'.format(STATIC_HELP, file_name)

        if not os.path.isfile(help_path) and not os.path.isdir(STATIC_HELP):
            help_path = u'{}/{}.html'.format(EN_HELP, file_name)
        help_url = QUrl()
        help_url.setPath(help_path)
        self._help_anchor = anchor_text
        self._help_text = text

        # allow JavaScript to run
        self.dynamic_help_box.page().settings().testAttribute(
            QWebSettings.JavascriptEnabled
        )
        self.dynamic_help_box.load(help_url)
项目:ReadManga    作者:kanishka-linux    | 项目源码 | 文件源码
def createRequest(self, op, request, device = None ):
        global lst
        try:
            path = str(request.url().path())
        except UnicodeEncodeError:
            pass
        lower_case = path.lower()
        #lst = tuple(open("easylist.txt", 'r'))
        lst = ["doubleclick.net" ,"ads",'.jpg','redirector','itag=','.png','.gif','.css','google','facebook','.aspx',r"http[^'].mp4",r"http[^'].flv", r"||youtube-nocookie.com/gen_204?", r"youtube.com###watch-branded-actions", "imagemapurl","b.scorecardresearch.com","rightstuff.com","scarywater.net","popup.js","banner.htm","_tribalfusion","||n4403ad.doubleclick.net^$third-party",".googlesyndication.com","graphics.js","fonts.googleapis.com/css","s0.2mdn.net","server.cpmstar.com","||banzai/banner.$subdocument","@@||anime-source.com^$document","google","/pagead2.","frugal.gif","jriver_banner.png","show_ads.js",'##a[href^="http://billing.frugalusenet.com/"]',"http://jriver.com/video.html","||animenewsnetwork.com^*.aframe?","||contextweb.com^$third-party",".gutter",".iab",'http://www.animenewsnetwork.com/assets/[^"]*.jpg']
        block = False
        for l in lst:
            if lower_case.find(l) != -1:
                block = True
                break
        if block:
            print ("Skipping")
            print (request.url().path())
            return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QtNetwork.QNetworkRequest(QtCore.QUrl()))
        else:
            return QNetworkAccessManager.createRequest(self, op, request, device)
项目:ReadManga    作者:kanishka-linux    | 项目源码 | 文件源码
def createRequest(self, op, request, device = None ):
        global lst
        try:
            path = str(request.url().path())
        except UnicodeEncodeError:
            pass
        lower_case = path.lower()
        #lst = tuple(open("easylist.txt", 'r'))
        lst = ["doubleclick.net" ,"ads",'.jpg','redirector','itag=','.png','.gif','.css','google','facebook','.aspx',r"http[^'].mp4",r"http[^'].flv", r"||youtube-nocookie.com/gen_204?", r"youtube.com###watch-branded-actions", "imagemapurl","b.scorecardresearch.com","rightstuff.com","scarywater.net","popup.js","banner.htm","_tribalfusion","||n4403ad.doubleclick.net^$third-party",".googlesyndication.com","graphics.js","fonts.googleapis.com/css","s0.2mdn.net","server.cpmstar.com","||banzai/banner.$subdocument","@@||anime-source.com^$document","google","/pagead2.","frugal.gif","jriver_banner.png","show_ads.js",'##a[href^="http://billing.frugalusenet.com/"]',"http://jriver.com/video.html","||animenewsnetwork.com^*.aframe?","||contextweb.com^$third-party",".gutter",".iab",'http://www.animenewsnetwork.com/assets/[^"]*.jpg']
        block = False
        for l in lst:
            if lower_case.find(l) != -1:
                block = True
                break
        if block:
            print ("Skipping")
            print (request.url().path())
            return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QtNetwork.QNetworkRequest(QtCore.QUrl()))
        else:
            return QNetworkAccessManager.createRequest(self, op, request, device)
项目:WebScraping    作者:liinnux    | 项目源码 | 文件源码
def open(self, url, timeout=60):
        """Wait for download to complete and return result"""
        loop = QEventLoop()
        timer = QTimer()
        timer.setSingleShot(True)
        timer.timeout.connect(loop.quit)
        self.loadFinished.connect(loop.quit)
        self.load(QUrl(url))
        timer.start(timeout * 1000)
        loop.exec_() # delay here until download finished
        if timer.isActive():
            # downloaded successfully
            timer.stop()
            return self.html()
        else:
            # timed out
            print 'Request timed out:', url
项目:WebScraping    作者:liinnux    | 项目源码 | 文件源码
def main():
    app = QApplication([])
    webview = QWebView()
    loop = QEventLoop()
    webview.loadFinished.connect(loop.quit)
    webview.load(QUrl('http://example.webscraping.com/search'))
    loop.exec_()

    webview.show()
    frame = webview.page().mainFrame()
    frame.findFirstElement('#search_term').setAttribute('value', '.')
    frame.findFirstElement('#page_size option:checked').setPlainText('1000')
    frame.findFirstElement('#search').evaluateJavaScript('this.click()')

    elements = None
    while not elements:
        app.processEvents()
        elements = frame.findAllElements('#results a')
    countries = [e.toPlainText().strip() for e in elements]
    print countries
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def __init__(self):
        """ Initialize main window. """
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.resize(QSize(settings.get('citewidth'),
                          settings.get('citeheight')))
        self.move(QPoint(settings.get('citex'),
                         settings.get('citey')))
        self.tabWidget.tabBar().setCurrentIndex(0)
        self.searchTab.setFocus()
        self.setWindowTitle('Cite')
        self.show()
        self.raise_()

        self.linkSettings()

        self.searchQuery.installEventFilter(self)
        self.text = self.bibtext = self.lastquery = ""
        self.batchBibtext = self.batchText = ""
        self.neverOpened = True

        self.helpText.setSource(QUrl('doc/help.html'))
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def wavelistDragEnterEvent(self, event):
        for fmt in event.mimeData().formats():
            if fmt.toLower().contains('text') or fmt.toLower().contains('string'):
                s = QtCore.QString(event.mimeData().data(fmt))
                if s.startsWith('file://'):
                    try:
                        path = str(QtCore.QUrl(s).toLocalFile())
                        source = wave.open(path)
                        if source.getnchannels() > 2 or source.getsampwidth() > 2:
                            raise
                        framerate = source.getframerate()
                        frames = source.getnframes()
                        if frames/float(framerate) > 60:
                            raise
                        break
                    except:
                        continue
        else:
            event.ignore()
            return
        event.accept()
        self.wave_accepted_fmt = fmt
项目:wswp    作者:kjam    | 项目源码 | 文件源码
def open(self, url, timeout=60):
        """Wait for download to complete and return result"""
        loop = QEventLoop()
        timer = QTimer()
        timer.setSingleShot(True)
        timer.timeout.connect(loop.quit)
        self.loadFinished.connect(loop.quit)
        self.load(QUrl(url))
        timer.start(timeout * 1000)
        loop.exec_() # delay here until download finished
        if timer.isActive():
            # downloaded successfully
            timer.stop()
            return self.html()
        else:
            # timed out
            print 'Request timed out:', url
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def createRequest(self, op, request, device = None ):
        global block_list
        try:
            path = str(request.url().toString())
        except UnicodeEncodeError:
            path = str(request.url().path())
            pass
        lower_path = path.lower()
        #lst = tuple(open("easylist.txt", 'r'))
        block_list = ["doubleclick.net" ,"ads", r"||youtube-nocookie.com/gen_204?", r"youtube.com###watch-branded-actions", "imagemapurl","b.scorecardresearch.com","rightstuff.com","scarywater.net","popup.js","banner.htm","_tribalfusion","||n4403ad.doubleclick.net^$third-party",".googlesyndication.com","graphics.js","fonts.googleapis.com/css","s0.2mdn.net","server.cpmstar.com","||banzai/banner.$subdocument","@@||anime-source.com^$document","/pagead2.","frugal.gif","jriver_banner.png","show_ads.js",'##a[href^="http://billing.frugalusenet.com/"]',"http://jriver.com/video.html","||animenewsnetwork.com^*.aframe?","||contextweb.com^$third-party",".gutter",".iab",'http://www.animenewsnetwork.com/assets/[^"]*.jpg','revcontent']
        block = False
        for l in block_list:
            if l in lower_path:
                block = True
                break
        if block:
            print ("Skipping")
            print (path)
            return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QtNetwork.QNetworkRequest(QtCore.QUrl()))
        else:
            return QNetworkAccessManager.createRequest(self, op, request, device)
项目:AnimeWatch    作者:kanishka-linux    | 项目源码 | 文件源码
def reviewsMusic(self,val):
        global name,nam,old_manager,new_manager,artist_name_mplayer,epnArrList,site
        self.HideEveryThing()
        #self.dockWidget_3.hide()

        self.tab_2.show()
        #self.web.show()
        old_manager = self.web.page().networkAccessManager()

        nam = NetWorkManager()
        self.web.page().setNetworkAccessManager(nam)
        if site == "Music":
            if str(self.list3.currentItem().text())=="Artist":
                nam1 = str(self.list1.currentItem().text())
            else:
                r = self.list2.currentRow()
                nam1 = epnArrList[r].split('    ')[2]
            print (nam1)
        else:
            nam1 = ""
        if val == "Last.Fm":
            self.web.load(QUrl("http://www.last.fm/search?q="+nam1))
        elif "TVDB:" in val:
            name1 = val.split(':')[-1]
            self.web.load(QUrl("http://thetvdb.com/?string="+name1+"&searchseriesid=&tab=listseries&function=Search"))
项目:Python-Web-Scraping-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def open(self, url, timeout=60):
        """Wait for download to complete and return result"""
        loop = QEventLoop()
        timer = QTimer()
        timer.setSingleShot(True)
        timer.timeout.connect(loop.quit)
        self.loadFinished.connect(loop.quit)
        self.load(QUrl(url))
        timer.start(timeout * 1000)
        loop.exec_() # delay here until download finished
        if timer.isActive():
            # downloaded successfully
            timer.stop()
            return self.html()
        else:
            # timed out
            print 'Request timed out:', url
项目:isogeo-plugin-qgis    作者:isogeo    | 项目源码 | 文件源码
def send_request_to_isogeo_api(self, token, limit=10):
        """Send a content url to the Isogeo API.

        This takes the currentUrl variable and send a request to this url,
        using the token variable.
        """
        myurl = QUrl(self.currentUrl)
        request = QNetworkRequest(myurl)
        request.setRawHeader("Authorization", token)
        if self.requestStatusClear is True:
            self.requestStatusClear = False
            api_reply = self.manager.get(request)
            api_reply.finished.connect(
                partial(self.handle_api_reply, answer=api_reply))
        else:
            pass

    # REQUEST and RESULTS ----------------------------------------------------
项目:isogeo-plugin-qgis    作者:isogeo    | 项目源码 | 文件源码
def ask_for_token(c_id, c_secret, request_status=True):
     """Ask a token from Isogeo API authentification page.

     This send a POST request to Isogeo API with the user id and secret in
     its header. The API should return an access token
     """
     headervalue = "Basic " + base64.b64encode(c_id + ":" + c_secret)
     data = urllib.urlencode({"grant_type": "client_credentials"})
     databyte = QByteArray()
     databyte.append(data)
     url = QUrl('https://id.api.isogeo.com/oauth/token')
     request = QNetworkRequest(url)
     request.setRawHeader("Authorization", headervalue)
     if request_status is True:
         request_status = False
         return request, databyte


     QgsMessageLog.logMessage("Authentication succeeded", "Isogeo")
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def open_log_file(self):
        assert self.last_log_file is not None
        QDesktopServices.openUrl(QUrl(self.last_log_file))
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def show_about(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Question)
        msg.setText("SpyKING CIRCUS v%s" %circus.__version__)
        msg.setWindowTitle("About")
        msg.setInformativeText("Documentation can be found at\n"
                                "http://spyking-circus.rtfd.org\n"
                                "\n"
                                "Open a browser to see the online help?"
            )
        msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
        msg.setDefaultButton(QMessageBox.No)
        answer = msg.exec_()
        if answer == QMessageBox.Yes:
            QDesktopServices.openUrl(QUrl("http://spyking-circus.rtfd.org"))
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def open_plot_folder(self):
        f_next, _ = os.path.splitext(str(self.ui.edit_file.text()))
        plot_folder = os.path.join(f_next, 'plots')
        QDesktopServices.openUrl(QUrl(plot_folder))
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def help_phy(self):
        QDesktopServices.openUrl(QUrl("https://github.com/kwikteam/phy-contrib"))
项目:spyking-circus    作者:spyking-circus    | 项目源码 | 文件源码
def help_matlab(self):
        QDesktopServices.openUrl(QUrl("http://ch.mathworks.com/products/matlab/"))
项目:transfer    作者:viur-framework    | 项目源码 | 文件源码
def request( url, params=None, secure=False, extraHeaders=None, successHandler=None, failureHandler=None, finishedHandler=None, parent=None ):
        global nam, _isSecureSSL
        if _isSecureSSL==False and False: #Warn the user of a potential security risk
            msgRes = QtGui.QMessageBox.warning( None, QtCore.QCoreApplication.translate("NetworkService", "Insecure connection"),
                                QtCore.QCoreApplication.translate("Updater", "The cacerts.pem file is missing or invalid. Your passwords and data will be send unsecured! Continue without encryption? If unsure, choose \"abort\"!"), 
                                QtCore.QCoreApplication.translate("NetworkService", "Continue in unsecure mode"),
                                QtCore.QCoreApplication.translate("NetworkService", "Abort") )
            if msgRes==0:
                _isSecureSSL=None
            else:
                sys.exit(1)
        if secure:
            key=securityTokenProvider.getKey()
            if not params:
                params = {}
            params["skey"] = key
        if url.lower().startswith("http"):
            reqURL = QUrl(url)
        else:
            reqURL = QUrl( NetworkService.url+url )
        req = QNetworkRequest( reqURL )
        if extraHeaders:
            for k, v in extraHeaders.items():
                req.setRawHeader( k,  v )
        if params:
            if isinstance( params, dict):
                multipart, boundary = NetworkService.genReqStr( params )
                req.setRawHeader( "Content-Type", b'multipart/form-data; boundary='+boundary+b'; charset=utf-8')
            elif isinstance( params, bytes ):
                req.setRawHeader( "Content-Type",  b'application/x-www-form-urlencoded' )   
                multipart = params
            else:
                print( params )
                print( type( params ) )
            return( RequestWrapper( nam.post( req, multipart ), url=url ).getResult() )
        else:
            return( RequestWrapper( nam.get( req ), url=url).getResult() )
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def resumeDownload(self):
        self.file = QtCore.QFile(self.filepath, self)
        request = QtNetwork.QNetworkRequest(QtCore.QUrl(self.url))
        if self.support_resume:
            self.loadedsize = self.file.size()
            if str(self.loadedsize) == self.totalsize : return
            request.setRawHeader('Range', 'bytes={}-'.format(self.loadedsize) )
        else:
            self.file.resize(0)
            self.loadedsize = 0
        self.download = self.nam.get(request)
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def downloadFile(self, index=0):
        self.file = QtCore.QFile(self.download_list[index][0], self)
        if self.file.exists():
            self.file.resize(0)
        req = QtNetwork.QNetworkRequest(QtCore.QUrl.fromUserInput(self.download_list[index][1]))
        req.setRawHeader('User-Agent', self.useragent)
        self.startDownload(req)
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def handleCssFiles(self):
        def repl(matchobj):
            src = matchobj.group(1).strip(' \'"')
            URL = QtCore.QUrl(src)
            if URL.isRelative():
                url = self.data_files.keys()[self.data_files.values().index(filename)]
                URL = QtCore.QUrl(url).resolved(URL)
                src = unicode(URL.toString().toUtf8())
            if src in self.data_files:
                src = os.path.basename(self.data_files[src])
            return 'url("' + src + '")'
        for filename in self.css_files:
            f = io.open(filename, 'r', encoding='utf-8')
            css = f.read()
            f.close()
            css = self.url_reg.sub(repl, css)
            f = io.open(filename, 'w', encoding='utf-8')
            css = f.write(css)
            f.close()
        for filename in self.child_frames:
            f = io.open(filename, 'r', encoding='utf-8')
            html = f.read()
            f.close()
            doc = self.doc.clone()
            doc.setInnerXml(html)
            page_URL = QtCore.QUrl( self.data_files.keys()[self.data_files.values().index(filename)] )
            SaveAsHtml(self.networkmanager, doc, filename, page_URL, self.useragent, True)
        if not self.childframe:
            trayIcon = Notifier(self)
            trayIcon.notify('Html Saved', 'Page has been saved as HTML')
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def repl(self, matchobj):
        ''' Resolve url("...") inside css '''
        src = matchobj.group(1).strip(' \'"')
        URL = QtCore.QUrl(src)
        if URL.isRelative():
            URL = self.page_URL.resolved(URL)
            src = unicode(URL.toString().toUtf8())
        return 'url("' + src + '")'
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def __init__(self, parent, networkmanager):
        QtWebKit.QWebPage.__init__(self, parent)
        self.setForwardUnsupportedContent(True)
        self.setLinkDelegationPolicy(2)
        self.setNetworkAccessManager(networkmanager)
        self.useragent = QtWebKit.QWebPage.userAgentForUrl(self, QtCore.QUrl())
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def downloadContent(self):
        src = QtCore.QUrl.fromUserInput(self.src_url)
        if src.isRelative():
            src = self.url().resolved(src)
        reqst = QtNetwork.QNetworkRequest(src)
        self.page().downloadRequested.emit(reqst)
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def downloadLink(self):
        request = QtNetwork.QNetworkRequest(QtCore.QUrl.fromUserInput(self.text()))
        self.downloadRequested.emit(request)
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def on_actionHelp_triggered (self):
        """Show help page."""
        url = QtCore.QUrl("%sindex.html" % DocBaseUrl)
        self.assistant.showDocumentation(url)
项目:PyIntroduction    作者:tody411    | 项目源码 | 文件源码
def mainPyQt4Youtube():
    # ?????????import
    from PyQt4.QtCore import QUrl
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView, QWebSettings
    from PyQt4.QtNetwork import QNetworkProxyFactory

    url = 'https://www.youtube.com/?hl=ja&gl=JP'

    app = QApplication(sys.argv)

    # Youtube????????????
    QNetworkProxyFactory.setUseSystemConfiguration(True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DnsPrefetchEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.LocalStorageEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)

    # QWebView???Web?????
    browser = QWebView()
    browser.load(QUrl(url))
    browser.setEnabled(True)
    browser.show()
    sys.exit(app.exec_())


## PyQt5??Web???????.
项目:orquesta    作者:ej-f    | 项目源码 | 文件源码
def open(self, fname):
        QDesktopServices.openUrl(QUrl('file:///' + fname))
项目:orquesta    作者:ej-f    | 项目源码 | 文件源码
def open(self, name):
        QDesktopServices.openUrl(QUrl('file://'+name))
项目:orquesta    作者:ej-f    | 项目源码 | 文件源码
def open_file(self, path):
        if os.path.isfile(path):
            QDesktopServices.openUrl(QUrl('file:///' + path))
        else:
            QMessageBox.warning(self, 'File doesn\'t exist', 'Var file not found for {}'.format(self.teminal_group))
项目:batch_gps_importer    作者:wondie    | 项目源码 | 文件源码
def on_show_static_help(self):
        static_help = StaticHelp(self)
        help_url = QUrl()
        help_path = os.path.join(STATIC_HELP, STATIC_HELP_FILE)
        if not os.path.isfile(help_path) and not os.path.isdir(STATIC_HELP):
            help_path = os.path.join(EN_HELP, STATIC_HELP_FILE)
        help_url.setPath(help_path)
        static_help.help_view.load(help_url)
        static_help.show()
项目:ReadManga    作者:kanishka-linux    | 项目源码 | 文件源码
def Browse(self,url):
        MainWindow = QtGui.QWidget()
        progress = QtGui.QProgressDialog("Please Wait", "Cancel", 0, 100, MainWindow)
        progress.setWindowModality(QtCore.Qt.WindowModal)
        progress.setAutoReset(True)
        progress.setAutoClose(True)
        progress.setMinimum(0)
        progress.setMaximum(100)
        progress.resize(500,100)
        progress.setWindowTitle("Loading, Please Wait! (Cloudflare Protection)")
        progress.show()
        progress.setValue(0)

        print('Browse: '+url)
        self.web = Browser(url)
        self.cookie = QtNetwork.QNetworkCookieJar()

        self.nam = NetWorkManager()
        self.nam.setCookieJar(self.cookie)

        self.web.page().setNetworkAccessManager(self.nam)
        self.web.load(QUrl(url))
        cnt = 0

        if 'kissmanga' in url:
            cookie_file = '/tmp/ReadManga/kcookieM.txt'

        while(not os.path.exists(cookie_file) and cnt < 60):
            print('wait '+str(cnt))
            time.sleep(1)
            QtGui.QApplication.processEvents()
            cnt = cnt+1
        if cnt >= 60 and not os.path.exists(cookie_file):
            f = open(cookie_file,'w')
            f.close()
        self.web.setHtml('<html>Cookie Obtained</html>')
        progress.setValue(100)
        progress.hide()
项目:ReadManga    作者:kanishka-linux    | 项目源码 | 文件源码
def Browse(self,url):
        MainWindow = QtGui.QWidget()
        progress = QtGui.QProgressDialog("Please Wait", "Cancel", 0, 100, MainWindow)
        progress.setWindowModality(QtCore.Qt.WindowModal)
        progress.setAutoReset(True)
        progress.setAutoClose(True)
        progress.setMinimum(0)
        progress.setMaximum(100)
        progress.resize(500,100)
        progress.setWindowTitle("Loading, Please Wait! (Cloudflare Protection)")
        progress.show()
        progress.setValue(0)

        print('Browse: '+url)
        self.web = Browser(url)
        self.cookie = QtNetwork.QNetworkCookieJar()

        self.nam = NetWorkManager()
        self.nam.setCookieJar(self.cookie)

        self.web.page().setNetworkAccessManager(self.nam)
        self.web.load(QUrl(url))
        cnt = 0

        if 'kissmanga' in url:
            cookie_file = '/tmp/ReadManga/kcookieM.txt'

        while(not os.path.exists(cookie_file) and cnt < 60):
            print('wait '+str(cnt))
            time.sleep(1)
            QtGui.QApplication.processEvents()
            cnt = cnt+1
        if cnt >= 60 and not os.path.exists(cookie_file):
            f = open(cookie_file,'w')
            f.close()
        self.web.setHtml('<html>Cookie Obtained</html>')
        progress.setValue(100)
        progress.hide()
项目:Comictagger    作者:dickloraine    | 项目源码 | 文件源码
def asyncFetchIssueCoverURLs( self, issue_id ):

        self.issue_id = issue_id
        details = self.fetchCachedIssueSelectDetails( issue_id )
        if details['image_url'] is not None:
            self.urlFetchComplete.emit( details['image_url'],details['thumb_image_url'], self.issue_id )
            return

        issue_url = self.api_base_url + "/issue/" + CVTypeID.Issue + "-" + str(issue_id) + "/?api_key=" + self.api_key + "&format=json&field_list=image,cover_date,site_detail_url"
        self.nam = QNetworkAccessManager()
        self.nam.finished.connect( self.asyncFetchIssueCoverURLComplete )
        self.nam.get(QNetworkRequest(QUrl(issue_url)))
项目:Comictagger    作者:dickloraine    | 项目源码 | 文件源码
def asyncFetchAlternateCoverURLs( self, issue_id, issue_page_url ):
        # This async version requires the issue page url to be provided!
        self.issue_id = issue_id
        url_list = self.fetchCachedAlternateCoverURLs( issue_id )
        if url_list is not None:
            self.altUrlListFetchComplete.emit( url_list, int(self.issue_id) )
            return

        self.nam = QNetworkAccessManager()
        self.nam.finished.connect( self.asyncFetchAlternateCoverURLsComplete )
        self.nam.get(QNetworkRequest(QUrl(str(issue_page_url))))
项目:Comictagger    作者:dickloraine    | 项目源码 | 文件源码
def fetch( self, url, user_data=None, blocking=False  ):
        """
        If called with blocking=True, this will block until the image is 
        fetched.

        If called with blocking=False, this will run the fetch in the 
        background, and emit a signal when done
        """

        self.user_data = user_data
        self.fetched_url = url

        # first look in the DB
        image_data = self.get_image_from_cache( url )

        if blocking:
            if image_data is None:
                try:
                    image_data = urllib.urlopen(url).read()
                except Exception as e:
                    print e
                    raise ImageFetcherException("Network Error!")

            # save the image to the cache
            self.add_image_to_cache( self.fetched_url, image_data ) 
            return image_data

        else:

            # if we found it, just emit the signal asap
            if image_data is not None:
                self.fetchComplete.emit( QByteArray(image_data), self.user_data )
                return

            # didn't find it.  look online
            self.nam = QNetworkAccessManager()
            self.nam.finished.connect(self.finishRequest)
            self.nam.get(QNetworkRequest(QUrl(url)))

            #we'll get called back when done...
项目:Comictagger    作者:dickloraine    | 项目源码 | 文件源码
def asyncGetLatestVersion( self, uuid, use_stats ):

        url = self.getRequestUrl( uuid, use_stats )

        self.nam = QNetworkAccessManager()
        self.nam.finished.connect( self.asyncGetLatestVersionComplete )
        self.nam.get(QNetworkRequest(QUrl(str(url))))
项目:webkit-crawler    作者:dozymoe    | 项目源码 | 文件源码
def load(self, url):
        self.web_view.load(QUrl(url))
项目:huhamhire-hosts    作者:jiangsile    | 项目源码 | 文件源码
def on_LinkActivated(self, url):
        """
        Open external link in browser.

        .. note:: This method is the slot responses to the signal from a Label
            widget while the text with a hyperlink which is clicked by user.
        """
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
项目:Open-Browser    作者:EricsonWillians    | 项目源码 | 文件源码
def compose_tab(self, index):
        self.tabs[index].append(CQWebView())
        self.tabs[index][0].setLayout(self.tabs[index][1])
        self.tabs[index][1].addWidget(self.tabs[index][2])
        self.tabs[index][2].page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.tabs[index][2].connect(self.tabs[index][2], QtCore.SIGNAL("linkClicked(const QUrl&)"), self.update_link)
        # To be implemented somehow... {
        self.tabs[index][2].connect(self.tabs[index][2], QtCore.SIGNAL("OPEN_IN_NEW_TAB"), lambda: [
            self.add_tab(len(self.tabs) - 1),
            None
        ])
        # }
        self.current_links.insert(index, self.url_field.text())
        self.update_link(QtCore.QUrl("http://www.google.com"))
        try:
            self.tabs[self.tab_stack.currentIndex()][2].loadProgress.connect(lambda: [self.tab_stack.setTabText(
                self.tab_stack.currentIndex(),
                "Loading..."
            ), (lambda x: self.star_button.setIcon(
                QtGui.QIcon(QtGui.QPixmap("GFX/star.png"))) if x not in self.bookmarks else self.star_button.setIcon(
                QtGui.QIcon(QtGui.QPixmap("GFX/removestar.png"))))(
                self.tabs[self.tab_stack.currentIndex()][2].page().mainFrame().findFirstElement(
                    "title").toPlainText())])
            self.tabs[self.tab_stack.currentIndex()][2].loadFinished.connect(lambda: self.tab_stack.setTabText(
                self.tab_stack.currentIndex(),
                self.tabs[self.tab_stack.currentIndex()][2].page().mainFrame().findFirstElement("title").toPlainText()
            ))
        except AttributeError as e:
            pass
        self.tabs[index][2].show()
项目:Open-Browser    作者:EricsonWillians    | 项目源码 | 文件源码
def load_page(self):
        self.visited.append((lambda s: s if "http" in s else (
        lambda x: x if ' ' not in x and '.' in x else "https://www.google.com/search?q=" + s)("https://" + s))(
            self.url_field.text()))
        self.tabs[self.tab_stack.currentIndex()][2].load(QtCore.QUrl(self.visited[-1]))
        self.current_index = len(self.visited) - 1
        self.current_links[self.tab_stack.currentIndex()] = self.url_field.text()
项目:Open-Browser    作者:EricsonWillians    | 项目源码 | 文件源码
def update_link(self, url):
        if type(url) == QtCore.QUrl:
            self.url_field.setText(url.toString())
            self.current_links[self.tab_stack.currentIndex()] = url.toString()
            self.tabs[self.tab_stack.currentIndex()][2].load(url)
        elif type(url) == str:
            self.url_field.setText(url)
            self.current_links[self.tab_stack.currentIndex()] = url
            self.tabs[self.tab_stack.currentIndex()][2].load(QtCore.QUrl(url))
        page_title = self.tabs[self.tab_stack.currentIndex()][2].page().mainFrame().findFirstElement(
            "title").toPlainText()
项目:Open-Browser    作者:EricsonWillians    | 项目源码 | 文件源码
def loadUrl(self, url):
        view = QtWebKit.QWebView()
        view.connect(view, QtCore.SIGNAL('loadFinished(bool)'), self.loadFinished)
        view.connect(view, QtCore.SIGNAL('linkClicked(const QUrl&)'), self.linkClicked)
        view.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.dbx_tabWidget.setCurrentIndex(self.dbx_tabWidget.addTab(view, 'loading...'))
        view.load(url)
项目:Open-Browser    作者:EricsonWillians    | 项目源码 | 文件源码
def generateCode(self):
        app_key = 'q6qqzbly9qycrot'
        app_secret_key = 'dmds9v8n328wzan'
        self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret_key)
        autorize_url = self.flow.start()
        self.loadUrl(QtCore.QUrl(autorize_url))