本文整理汇总了Python中urllib._unquote函数的典型用法代码示例。如果您正苦于以下问题:Python _unquote函数的具体用法?Python _unquote怎么用?Python _unquote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_unquote函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: textExtraction
def textExtraction(wikidocument, lang):
#extract the body part
body=_body_re.search(wikidocument).group(1)
#list internal links
internal_links=[(lang, _unquote(url)) for (url, document_name) in _internal_link.findall(body)]
#list interlanguage links
interlanguage_links=[(lang_ref, _unquote(url)) for (lang_ref, url) in _interlanguage_link.findall(body)]
#replace links
body=_link_re.sub((lambda match: match.group(2)), body)
#supress table toc
body=_table_toc_re.sub("\n", body)
#supress imgages
body=_img_re.sub("", body)
#supress scripts
body=_script_re.sub("", body)
#supress citations
body=_cite_re.sub("", body)
#supress sups
body=_sup_re.sub((lambda match: match.group(1)), body)
#supress tables
body=_table_re.sub("\n", body)
##supress everything after "see also"
#see_also_re=_re.compile("<h2><span class=\"mw-headline\" id=\"Voir_aussi\">Voir aussi</span></h2>", _re.DOTALL)
#match=see_also_re.search(body)
#if match:
#body=body[:match.start()]
#only keeps p and hx
body="\n".join(_p_and_hx_re.findall(body))
#remove (formating) tags
body=_tags_re.sub("", body)
#the following is coding dependant
body=body.decode("utf8")
#split lines
body=_end_line_re.sub((lambda match: match.group(0)+"\n"), body)
#encoding normalization
body=_entity_re.sub(_entity_callback, body)
return (body.encode("utf8"), internal_links, interlanguage_links)
开发者ID:ankurgupta8907,项目名称:info_retrieval_project,代码行数:57,代码来源:textextraction.py
示例2: unquote
def unquote(s):
s = _unquote(s)
# PY3 always returns unicode. PY2 seems to always return what you give it,
# which differs from quote's behavior. Just to be safe, make sure it is
# unicode before we return.
if isinstance(s, bytes_type):
s = s.decode('utf-8')
return s
开发者ID:aqeelahamad,项目名称:searching,代码行数:8,代码来源:common.py
示例3: getUrlParams
def getUrlParams(url=None):
if url is None:
url = getEnv('REQUEST_URI')
url = urlparse(url)
return dict([(part.split('=')[0], _unquote(part.split('=')[1])) for part in url[4].split('&') if len(part.split('=')) == 2])
开发者ID:ajiexw,项目名称:old-zarkpy,代码行数:5,代码来源:site_helper.py
示例4: unquote
def unquote(string):
if type(string) is unicode:
string = string.encode('utf-8')
return _unquote(string)
开发者ID:ajiexw,项目名称:old-zarkpy,代码行数:4,代码来源:site_helper.py
示例5: unquote
def unquote(s):
return networkString(_unquote(nativeString(s)))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:2,代码来源:postfix.py
示例6: unquote
def unquote(x):
if isinstance(x, unicode):
x = x.encode('utf-8')
return _unquote(x).decode('utf-8')
开发者ID:artbycrunk,项目名称:calibre,代码行数:4,代码来源:chm_input.py
示例7: unquote
def unquote(*l):
return tuple(_unquote(unicodeToStr(s)) for s in l) if len(l) != 1 else _unquote(unicodeToStr(l[0]))
开发者ID:duoduo369,项目名称:zarkpy,代码行数:2,代码来源:site_helper.py
示例8: unquote
def unquote(s):
return unicode(_unquote(s.encode("utf-8")), "utf-8")
开发者ID:MwzkQmuUZkFLbXm,项目名称:me,代码行数:2,代码来源:common.py
示例9: unquote
def unquote(s):
return _unquote(s.encode('utf-8')).decode('utf-8')
开发者ID:sopel-irc,项目名称:sopel,代码行数:2,代码来源:search.py
示例10: unquote
def unquote(string):
assert(type(string) in [unicode, str])
return _unquote(string.encode('utf-8')) if isinstance(string, unicode) else _unquote(string)
开发者ID:alliadt,项目名称:zarkpy,代码行数:3,代码来源:site_helper.py
示例11: unquote_to_bytes
def unquote_to_bytes(data):
if isinstance(data, unicode):
data = data.encode('ascii')
return _unquote(data)
开发者ID:cleitner,项目名称:WeasyPrint,代码行数:4,代码来源:compat.py
示例12: unquote
def unquote(data, encoding='utf-8', errors='replace'):
return _unquote(data).encode('latin1').decode(encoding, errors)
开发者ID:cleitner,项目名称:WeasyPrint,代码行数:2,代码来源:compat.py
示例13: _unquote
# coding=utf-8
# Copyright 2008-9, Sean B. Palmer, inamidst.com
# Copyright 2012, Elsie Powell, embolalia.com
# Licensed under the Eiffel Forum License 2.
from __future__ import unicode_literals, absolute_import, print_function, division
import re
import sys
if sys.version_info.major < 3:
from urllib import unquote as _unquote
unquote = lambda s: _unquote(s.encode('utf-8')).decode('utf-8')
else:
from urllib.parse import unquote
import requests
import xmltodict
from sopel import web
from sopel.module import commands, example
def formatnumber(n):
"""Format a number with beautiful commas."""
parts = list(str(n))
for i in range((len(parts) - 3), 0, -3):
parts.insert(i, ',')
return ''.join(parts)
r_bing = re.compile(r'<h2(?: class=" b_topTitle")?><a href="([^"]+)"')
开发者ID:neonobjclash,项目名称:sopel,代码行数:31,代码来源:search.py
注:本文中的urllib._unquote函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论