Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47956
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dotancohen@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'importing': 0.05; 'urllib2': 0.07; 'string': 0.09; 'function:': 0.09; 'overflow': 0.09; 'rfc': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'def': 0.12; '(via': 0.16; 'non-ascii': 0.16; 'subject: \n ': 0.16; 'subject:URL': 0.16; 'subject:when': 0.16; 'symbols': 0.16; 'url)': 0.16; 'urllib': 0.16; 'module': 0.19; 'stack': 0.19; 'import': 0.22; 'issue.': 0.22; '[1]': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'requests': 0.31; 'received:google.com': 0.35; 'subject:?': 0.36; 'remote': 0.38; 'sometimes': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'wonderful': 0.60; 'such': 0.63; 'url:co': 0.67; 'skip:r 40': 0.68; 'url:a': 0.72; 'subject:Must': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=HGVK8pVDSFZ566i59QdPNOHFeHC5r52lvm4tpP1vBKM=; b=rhLKgI7vvZA3/frmlh4pb1ErJSblj8ciqb50Ndqk+1X0VKtqUSLII2iZqHwAYbtSCB OERgSApWdxWyxOeD2FDHjs5L88tu/v/7YI5k0t8vX4IieD7ylaijOFePbOKuMHw7b8i4 2BYHkkd5/rnv0EB0P+zkECYfI0dNSfTdDHERXdjUWi6ScOv/jd0IGRIoIv2ALBaV2meO OoBE6E0taipbfL9Sk6iOtHUkPnzC6XxOjVxb/Zq8B27+PIG8SI+0cJB2FyePftb05eht gzgWQUhPXpaQ58sPgBtBScM84pC/J9roiC/MikJ8aibi8kidqUrlYfLCUCpPjIbSCdmM ixIQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.100.35 with SMTP id ev3mr997620wib.12.1371128720975; Thu, 13 Jun 2013 06:05:20 -0700 (PDT) |
| Date | Thu, 13 Jun 2013 16:05:20 +0300 |
| Subject | Must we include urllib just to decode a URL-encoded string, when using Requests? |
| From | Dotan Cohen <dotancohen@gmail.com> |
| To | "python-list." <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3188.1371128728.3114.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371128728 news.xs4all.nl 15932 [2001:888:2000:d::a6]:49737 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:47956 |
Show key headers only | View raw
I am using the Requests module to access remote URLs. Sometimes I need
to URL-decode or URL-encode a string (via RFC 3986). Must I import
urllib or urllib2 just to use their quote() and unquote() methods?
Does not Requests have such an ability, and perhaps I just cannot find
it?
On Stack Overflow [1] I found this wonderful function:
def unquote(url):
return re.compile('%([0-9a-fA-F]{2})',re.M).sub(lambda m:
chr(int(m.group(1),16)), url)
I am already importing the 're' module so that is not an issue. I am
concerned, though, that this might not work for some non-ASCII
characters such as some esoteric symbols or Korean/Chinese/Japanese
characters.
[1] http://stackoverflow.com/a/15627281/343302
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Must we include urllib just to decode a URL-encoded string, when using Requests? Dotan Cohen <dotancohen@gmail.com> - 2013-06-13 16:05 +0300
csiph-web