當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。