本文整理汇总了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
示例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)))
示例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))))
示例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...
示例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))))
示例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)