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


Python QtNetwork.QNetworkAccessManager方法代码示例

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


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

示例1: createRequest

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
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 
开发者ID:ksharindam,项目名称:quartz-browser,代码行数:26,代码来源:webkit.py

示例2: asyncFetchIssueCoverURLs

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
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))) 
开发者ID:dickloraine,项目名称:Comictagger,代码行数:14,代码来源:comicvinetalker.py

示例3: asyncFetchAlternateCoverURLs

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
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)))) 
开发者ID:dickloraine,项目名称:Comictagger,代码行数:13,代码来源:comicvinetalker.py

示例4: fetch

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
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... 
开发者ID:dickloraine,项目名称:Comictagger,代码行数:42,代码来源:imagefetcher.py

示例5: asyncGetLatestVersion

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
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)))) 
开发者ID:dickloraine,项目名称:Comictagger,代码行数:9,代码来源:versionchecker.py

示例6: __init__

# 需要导入模块: from PyQt4 import QtNetwork [as 别名]
# 或者: from PyQt4.QtNetwork import QNetworkAccessManager [as 别名]
def __init__(self,config):

        self.Config = config

        super(weatherWidget, self).__init__()

        self.manager = QtNetwork.QNetworkAccessManager()
  
        stimer = QtCore.QTimer()
        stimer.singleShot(2000, self.qtstart) 
开发者ID:jtsmith2,项目名称:pyDashboard,代码行数:12,代码来源:WeatherWidget.py


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