All Samples(105) | Call(90) | Derive(0) | Import(15)
quote('abc def') -> 'abc%20def'
Each part of a URL, e.g. the path info, the query, etc., has a
different set of reserved characters that must be quoted.
RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
the following reserved characters.
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
"$" | ","
Each of these characters is reserved in some component of a URL,
but not necessarily in all of them.
By default, the quote function is intended for quoting the path
section of a URL. Thus, it will not encode '/'. This character
is reserved, but in typical usage the quote function is being
called on a path where the existing slash characters are used as
reserved characters.
def quote(s, safe='/'):
"""quote('abc def') -> 'abc%20def'
Each part of a URL, e.g. the path info, the query, etc., has a
different set of reserved characters that must be quoted.
RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
the following reserved characters.
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
"$" | ","
Each of these characters is reserved in some component of a URL,
but not necessarily in all of them.
By default, the quote function is intended for quoting the path
section of a URL. Thus, it will not encode '/'. This character
is reserved, but in typical usage the quote function is being
called on a path where the existing slash characters are used as
reserved characters.
"""
# fastpath
if not s:
return s
cachekey = (safe, always_safe)
try:
(quoter, safe) = _safe_quoters[cachekey]
except KeyError:
safe_map = _safe_map.copy()
safe_map.update([(c, c) for c in safe])
quoter = safe_map.__getitem__
safe = always_safe + safe
_safe_quoters[cachekey] = (quoter, safe)
if not s.rstrip(safe):
return s
return ''.join(map(quoter, s))
if exists(cache):
return unicode(file(cache).read(), 'utf-8')
title = urllib2.quote(title)
url = 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=' + title
text = urllib2.urlopen(url).read()
data = json.loads(text)
src/s/n/sncf-HEAD/sncf_moins_cher.py sncf(Download)
'inward_time': opts.inward_time}
for k, v in search_params.items():
search_params[k] = v and urllib2.quote(str(v), safe='') or ''
search_url = 'http://www.voyages-sncf.com/weblogic/expressbooking/_SvExpressBooking?' \
'bookingChoice=train&origin_city=%(origin_city)s&destination_city=' \
src/a/m/amgGenre-HEAD/amgGenre.py amgGenre(Download)
u(0, 'direct lookup found: ' + m.group(1)) genresList = grabGenre(infoURL + m.group(1)) elif not single: optionlist = grab(albumSearchURL + urllib2.quote(title, safe=urlSafeSearch), r'trlink".*?"cell">(?P<year>\d\d\d\d).*?word;">(?P<artist>.*?)</TD.*?(?P<link>sql=10:.*?)">(?P<title>.*?)</.*?-word;">(?P<label>.*?)</', 'search', artist) searcharg = arg
sys.exit() if selected[0] == 'opt1=1&sql=Artist': u(0, "Searching on artist: " + artist) newUrl = grab(artistSearchURL + urllib2.quote(artist, safe=urlSafeSearch), r'(?P<discoglink>sql=11:[0-9a-z]*?~T2)">Discography', 'single', artist) optionlist = grab(infoURL + newUrl[0],
# print "No genre! Completely boring music, apparently." else: #Chokes if search doesn't return a direct link to an artist genresList = grabGenre(artistSearchURL + urllib2.quote(artist, safe=urlSafeSearch), False) break if not genresList == None: total = len(os.listdir(arg))
src/p/i/pipe2py-HEAD/modules/pipeurlinput.py pipe2py(Download)
value = context.inputs.get(name, default)
#Ensure url is valid
value = urllib2.quote(value, safe="%/:=&?~#+!$,;'@()*[]")
while True:
yield value
src/p/i/pipe2py-HEAD/modules/pipeurlbuilder.py pipe2py(Download)
url = url.rstrip("/")
#Ensure url is valid
url = urllib2.quote(url, safe="%/:=&?~#+!$,;'@()*[]")
params = dict([(util.get_value(p['key'], item, **kwargs), util.get_value(p['value'], item, **kwargs)) for p in conf['PARAM']])
if params:
src/x/s/xsser-HEAD/xsser/dork.py xsser(Download)
(http://en.wikipedia.org/wiki/List_of_search_engines)
"""
if self._engine == 'bing' or not self._engine:
search_url = "http://www.bing.com/search?q=" + urllib2.quote(search)
elif self._engine == 'scroogle':
search_url = "http://www.scroogle.org/cgi-bin/nbbw.cgi?q=" + urllib2.quote(search)
elif self._engine == 'altavista':
search_url = "http://es.altavista.com/web/results?fr=altavista&itag=ody&q=" + urllib2.quote(search)
elif self._engine == 'duck':
search_url = "https://duckduckgo.com/?q=" + urllib2.quote(search)
elif self._engine == 'baidu':
search_url = "http://www.baidu.com/s?wd=" + urllib2.quote(search)
elif self._engine == 'yandex':
search_url = "http://yandex.ru/yandsearch?text=" + urllib2.quote(search)
elif self._engine == 'yandex':
search_url = "http://yandex.ru/yandsearch?text=" + urllib2.quote(search)
elif self._engine == 'yebol':
search_url = "http://www.yebol.com/a.jsp?x=0&y=0&key=" + urllib2.quote(search)
elif self._engine == 'youdao':
search_url = "http://www.youdao.com/search?q=" + urllib2.quote(search)
elif self._engine == 'ask':
search_url = "http://www.ask.com/web?q=" + urllib2.quote(search)
elif self._engine == 'google':
search_url = "http://www.google.com/search?q=" + urllib2.quote(search)
elif self._engine == 'yahoo':
search_url = "http://search.yahoo.com/search?p=" + urllib2.quote(search)
src/p/y/python-tvrage-HEAD/tvrage/quickinfo.py python-tvrage(Download)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from urllib2 import urlopen, URLError, quote
from util import _fetch
from exceptions import ShowNotFound
BASE_URL = 'http://services.tvrage.com/tools/quickinfo.php'
def fetch(show, exact=False, ep=None):
query_string = '?show=' + quote(show)
def fetch(show, exact=False, ep=None):
query_string = '?show=' + quote(show)
if exact:
query_string = query_string + '&exact=1'
if ep:
query_string = query_string + '&ep=' + quote(ep)
resp = _fetch(BASE_URL + query_string).read()
src/s/p/springenwerk-HEAD/trunk/springenwerk.py springenwerk(Download)
postData = ""
for origParam in params.keys():
if (origParam != pToBeChecked):
postData += origParam + "=" + urllib2.quote(params[origParam]) + "&"
postData += pToBeChecked + "=" + urllib2.quote(htmlControlString) + pToBeChecked
if (self.verbose):
for origParam in params.keys():
if (origParam != pToBeChecked):
untouchedParams += origParam + "=" + urllib2.quote(params[origParam]) + "&"
urlWithParams += untouchedParams + pToBeChecked + "=" + urllib2.quote(htmlControlString) + pToBeChecked
src/s/p/springenwerk-HEAD/springenwerk.py springenwerk(Download)
postData = ""
for origParam in params.keys():
if (origParam != pToBeChecked):
postData += origParam + "=" + urllib2.quote(params[origParam]) + "&"
postData += pToBeChecked + "=" + urllib2.quote(htmlControlString) + pToBeChecked
if (self.verbose):
for origParam in params.keys():
if (origParam != pToBeChecked):
untouchedParams += origParam + "=" + urllib2.quote(params[origParam]) + "&"
urlWithParams += untouchedParams + pToBeChecked + "=" + urllib2.quote(htmlControlString) + pToBeChecked
src/c/o/ConceptNet-4.0rc4/csc/webapi/rest_client.py ConceptNet(Download)
def _get_json(*url_parts):
url = API_URL + '/'.join(urllib2.quote(str(p)) for p in url_parts) + '/query.json'
return json.loads(_get_url(url))
def _post_json(url_parts, post_parts):
url = API_URL + '/'.join(urllib2.quote(str(p)) for p in url_parts) + '/query.json'
postdata = urllib.urlencode(post_parts)
req = urllib2.Request(url, postdata)
response = urllib2.urlopen(req)
return json.loads(response.read())
def _extend_url(old_url, *url_parts):
url = old_url + '/'.join(urllib2.quote(str(p)) for p in url_parts) + '/'
1 | 2 | 3 | 4 | 5 Next