本文整理汇总了Python中PyQt4.QtCore.QUrl.fromPercentEncoding方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.fromPercentEncoding方法的具体用法?Python QUrl.fromPercentEncoding怎么用?Python QUrl.fromPercentEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.fromPercentEncoding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import fromPercentEncoding [as 别名]
def search(url, callback):
QgsMessageLog.logMessage("URL:" + url, "Gazetteer")
def requestFinished(reply):
# Disconnect from the signal
networkAccessManager = QgsNetworkAccessManager.instance()
networkAccessManager.finished.disconnect(requestFinished)
# Handle the reply
if reply.error() != QNetworkReply.NoError:
QgsMessageLog.logMessage("Network error #{0}: {1}".format(reply.error(), reply.errorString()), "Gazetteer")
callback(u'')
else:
charset = 'UTF-8'
try:
_, params = cgi.parse_header(reply.header(QNetworkRequest.ContentTypeHeader))
charset = params['charset']
except:
pass
QgsMessageLog.logMessage("charset: " + charset, "Gazetteer")
data = unicode(reply.readAll(), charset)
reply.deleteLater()
callback(data)
networkAccessManager = QgsNetworkAccessManager.instance()
networkAccessManager.finished.connect(requestFinished)
networkAccessManager.get(QNetworkRequest(QUrl(QUrl.fromPercentEncoding(url))))
示例2: __parseTask
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import fromPercentEncoding [as 别名]
def __parseTask(self, task):
"""
:type task: QUrl
:return: dict
"""
taskMap = {u'action': task.path()}
for key, value in task.encodedQueryItems():
taskMap[unicode(key)] = QUrl.fromPercentEncoding(unicode(value))
return taskMap
示例3: __test
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import fromPercentEncoding [as 别名]
def __test():
db_location = StoragePath + "database_test"
import os
if os.path.exists(db_location):
os.remove(db_location)
createTable()
# jiawzhang XXX: The string to be saved to sqlite must be unicode first, otherwise, error happens.
userInfo = UserInfo(
u"代理梦想家80后",
u"http://item.taobao.com/item.htm?id=9248227645",
unicode(
QUrl.fromPercentEncoding(
u"http://www.taobao.com/webww/?ver=1&&touid=cntaobao%E4%BB%A3%E7%90%86%E6%A2%A6%E6%83%B3%E5%AE%B680%E5%90%8E&siteid=cntaobao&status=1&portalId=&gid=9190349629&itemsId="
)
),
0.80,
1.00,
)
saveUser(userInfo)
saveUser(userInfo)
userInfo.last_status_time = datetime.now() - timedelta(31)
saveUser(userInfo)
"get all users"
users = getObjects(UserInfo, "select * from user_info")
userInfo = users[0]
for user in users:
print user
print "update active = 0 and then get usersMonthly:"
updateUser(userInfo, active=0)
print "userInfo.active: " + str(userInfo.active)
print "__getUsersMonthly"
users = __getUsersMonthly()
for user in users:
print user
print "getActiveByTaobaoId"
userInfo = getActiveUserByTaobaoId(u"代理梦想家80后")
print userInfo
print "getUnhandledUserInfoList"
userInfos = getUnhandledUserInfoList()
for userInfo in userInfos:
print userInfo
示例4: handle_unsupported_content
# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import fromPercentEncoding [as 别名]
def handle_unsupported_content(self, reply):
"""
Called basically when the reply from the request is not HTML
or something else renderable by qwebview
"""
self.reply = reply
self.content_type = self.reply.header(QNetworkRequest.ContentTypeHeader).toString()
self.content_filename = re.match('.*;\s*filename=(.*);', self.reply.rawHeader('Content-Disposition'))
self.content_filename = QUrl.fromPercentEncoding((self.content_filename and self.content_filename.group(1)) or '')
content_url = self.reply.url()
debug("Loading url %s of type %s" % (content_url.toString(), self.content_type))
if not self.content_handlers.get(str(self.content_type)):
self.setHtml(UNKNOWN_CONTENT_TYPE % (self.content_type,
self.content_filename,
content_url.toString()))
else:
if str(self.url().toString()) in ('', 'about:blank'):
self.setHtml(DOWNLOADING_MESSAGE % (self.content_filename,
self.content_type,
content_url.toString()))
else:
# print(self.url())
self.load(self.url())
self.connect(self.reply, SIGNAL("finished()"), self.display_downloaded_content)