当前位置: 首页>>代码示例>>Python>>正文


Python QNetworkRequest.url方法代码示例

本文整理汇总了Python中PyQt5.QtNetwork.QNetworkRequest.url方法的典型用法代码示例。如果您正苦于以下问题:Python QNetworkRequest.url方法的具体用法?Python QNetworkRequest.url怎么用?Python QNetworkRequest.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtNetwork.QNetworkRequest的用法示例。


在下文中一共展示了QNetworkRequest.url方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: acceptNavigationRequest

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
    def acceptNavigationRequest(self,
                                _frame: QWebFrame,
                                request: QNetworkRequest,
                                typ: QWebPage.NavigationType):
        """Override acceptNavigationRequest to handle clicked links.

        Setting linkDelegationPolicy to DelegateAllLinks and using a slot bound
        to linkClicked won't work correctly, because when in a frameset, we
        have no idea in which frame the link should be opened.

        Checks if it should open it in a tab (middle-click or control) or not,
        and then conditionally opens the URL. Opening it in a new tab/window
        is handled in the slot connected to link_clicked.
        """
        url = request.url()
        target = self._tabdata.combined_target()
        log.webview.debug("navigation request: url {}, type {}, "
                          "target {}".format(
                              url.toDisplayString(),
                              debug.qenum_key(QWebPage, typ),
                              target))

        if typ == QWebPage.NavigationTypeReload:
            self.reloading.emit(url)
            return True
        elif typ != QWebPage.NavigationTypeLinkClicked:
            return True

        self.link_clicked.emit(url)

        return url.isValid() and target == usertypes.ClickTarget.normal
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:33,代码来源:webpage.py

示例2: download

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
 def download(self, requestOrUrl, requestFileName=False, mainWindow=None):
     """
     Public method to download a file.
     
     @param requestOrUrl reference to a request object (QNetworkRequest)
         or a URL to be downloaded (QUrl)
     @keyparam requestFileName flag indicating to ask for the
         download file name (boolean)
     @keyparam mainWindow reference to the main window (HelpWindow)
     """
     request = QNetworkRequest(requestOrUrl)
     if request.url().isEmpty():
         return
     self.handleUnsupportedContent(
         self.__manager.get(request), requestFileName=requestFileName, download=True, mainWindow=mainWindow
     )
开发者ID:paulmadore,项目名称:Eric-IDE,代码行数:18,代码来源:DownloadManager.py

示例3: acceptNavigationRequest

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
    def acceptNavigationRequest(self,
                                _frame: QWebFrame,
                                request: QNetworkRequest,
                                typ: QWebPage.NavigationType):
        """Override acceptNavigationRequest to handle clicked links.

        Setting linkDelegationPolicy to DelegateAllLinks and using a slot bound
        to linkClicked won't work correctly, because when in a frameset, we
        have no idea in which frame the link should be opened.

        Checks if it should open it in a tab (middle-click or control) or not,
        and then conditionally opens the URL here or in another tab/window.
        """
        url = request.url()
        log.webview.debug("navigation request: url {}, type {}, "
                          "target {} override {}".format(
                              url.toDisplayString(),
                              debug.qenum_key(QWebPage, typ),
                              self.open_target,
                              self._tabdata.override_target))

        if self._tabdata.override_target is not None:
            target = self._tabdata.override_target
            self._tabdata.override_target = None
        else:
            target = self.open_target

        if typ == QWebPage.NavigationTypeReload:
            self.reloading.emit(url)
            return True
        elif typ != QWebPage.NavigationTypeLinkClicked:
            return True

        if not url.isValid():
            msg = urlutils.get_errstring(url, "Invalid link clicked")
            message.error(msg)
            self.open_target = usertypes.ClickTarget.normal
            return False

        if target == usertypes.ClickTarget.normal:
            return True

        tab = shared.get_tab(self._win_id, target)
        tab.openurl(url)
        self.open_target = usertypes.ClickTarget.normal
        return False
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:48,代码来源:webpage.py

示例4: acceptNavigationRequest

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
    def acceptNavigationRequest(self,
                                frame: QWebFrame,
                                request: QNetworkRequest,
                                typ: QWebPage.NavigationType) -> bool:
        """Override acceptNavigationRequest to handle clicked links.

        Setting linkDelegationPolicy to DelegateAllLinks and using a slot bound
        to linkClicked won't work correctly, because when in a frameset, we
        have no idea in which frame the link should be opened.

        Checks if it should open it in a tab (middle-click or control) or not,
        and then conditionally opens the URL here or in another tab/window.
        """
        type_map = {
            QWebPage.NavigationTypeLinkClicked:
                usertypes.NavigationRequest.Type.link_clicked,
            QWebPage.NavigationTypeFormSubmitted:
                usertypes.NavigationRequest.Type.form_submitted,
            QWebPage.NavigationTypeFormResubmitted:
                usertypes.NavigationRequest.Type.form_resubmitted,
            QWebPage.NavigationTypeBackOrForward:
                usertypes.NavigationRequest.Type.back_forward,
            QWebPage.NavigationTypeReload:
                usertypes.NavigationRequest.Type.reloaded,
            QWebPage.NavigationTypeOther:
                usertypes.NavigationRequest.Type.other,
        }
        is_main_frame = frame is self.mainFrame()
        navigation = usertypes.NavigationRequest(url=request.url(),
                                                 navigation_type=type_map[typ],
                                                 is_main_frame=is_main_frame)

        if navigation.navigation_type == navigation.Type.reloaded:
            self.reloading.emit(navigation.url)

        self.navigation_request.emit(navigation)
        return navigation.accepted
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:39,代码来源:webpage.py

示例5: doRequest

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
 def doRequest(request: QNetworkRequest, body: Optional[bytes] = None, *_):
     key = method.upper(), request.url().toString()
     if body:
         self.request_bodies[key] = body
     return self.replies[key]
开发者ID:TinkerGnome,项目名称:Cura,代码行数:7,代码来源:NetworkManagerMock.py

示例6: createRequest

# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import url [as 别名]
 def createRequest(self, op, request, outgoingData=None):
     """
     Public method to create a request.
     
     @param op the operation to be performed
         (QNetworkAccessManager.Operation)
     @param request reference to the request object (QNetworkRequest)
     @param outgoingData reference to an IODevice containing data to be sent
         (QIODevice)
     @return reference to the created reply object (QNetworkReply)
     """
     scheme = request.url().scheme()
     if scheme == "https" and \
             (not SSL_AVAILABLE or not QSslSocket.supportsSsl()):
         from .NetworkProtocolUnknownErrorReply import \
             NetworkProtocolUnknownErrorReply
         return NetworkProtocolUnknownErrorReply(scheme, self)
     
     import Helpviewer.HelpWindow
     
     if op == QNetworkAccessManager.PostOperation and \
             outgoingData is not None:
         outgoingDataByteArray = outgoingData.peek(1024 * 1024)
         Helpviewer.HelpWindow.HelpWindow.passwordManager().post(
             request, outgoingDataByteArray)
     
     reply = None
     if scheme in self.__schemeHandlers:
         reply = self.__schemeHandlers[scheme]\
                     .createRequest(op, request, outgoingData)
     if reply is not None:
         return reply
     
     # give GreaseMonkey the chance to create a request
     reply = Helpviewer.HelpWindow.HelpWindow.greaseMonkeyManager()\
         .createRequest(op, request, outgoingData)
     if reply is not None:
         return reply
     
     req = QNetworkRequest(request)
     if req.rawHeader(b"X-Eric6-UserLoadAction") == QByteArray(b"1"):
         req.setRawHeader(b"X-Eric6-UserLoadAction", QByteArray())
         req.setAttribute(QNetworkRequest.User + 200, "")
     else:
         req.setAttribute(
             QNetworkRequest.User + 200, req.rawHeader(b"Referer"))
     
     if hasattr(QNetworkRequest, 'HttpPipeliningAllowedAttribute'):
         req.setAttribute(
             QNetworkRequest.HttpPipeliningAllowedAttribute, True)
     if not self.__acceptLanguage.isEmpty():
         req.setRawHeader(b"Accept-Language", self.__acceptLanguage)
     
     # AdBlock code
     if op == QNetworkAccessManager.GetOperation:
         if self.__adblockNetwork is None:
             self.__adblockNetwork = \
                 Helpviewer.HelpWindow.HelpWindow.adBlockManager().network()
         reply = self.__adblockNetwork.block(req)
         if reply is not None:
             reply.setParent(self)
             return reply
     
     # set cache policy
     if op == QNetworkAccessManager.GetOperation:
         urlHost = req.url().host()
         for host in Preferences.getHelp("NoCacheHosts"):
             if host in urlHost:
                 req.setAttribute(
                     QNetworkRequest.CacheLoadControlAttribute,
                     QNetworkRequest.AlwaysNetwork)
                 break
         else:
             req.setAttribute(
                 QNetworkRequest.CacheLoadControlAttribute,
                 Preferences.getHelp("CachePolicy"))
     else:
         req.setAttribute(
             QNetworkRequest.CacheLoadControlAttribute,
             QNetworkRequest.AlwaysNetwork)
     
     # Do Not Track feature
     if self.__doNotTrack:
         req.setRawHeader(b"DNT", b"1")
         req.setRawHeader(b"X-Do-Not-Track", b"1")
     
     # Send referer header?
     if not self.__sendReferer and \
        req.url().host() not in Preferences.getHelp("SendRefererWhitelist"):
         req.setRawHeader(b"Referer", b"")
     
     reply = QNetworkAccessManager.createRequest(
         self, op, req, outgoingData)
     self.requestCreated.emit(op, req, reply)
     
     return reply
开发者ID:testmana2,项目名称:test,代码行数:98,代码来源:NetworkAccessManager.py


注:本文中的PyQt5.QtNetwork.QNetworkRequest.url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。