urlencode

Why is the comma URL encoded?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 04:27:27
When debugging in ASP.NET MVC, I don't see a difference between: http://mysite.com?q=hi,bye and http://mysite.com?q=hi%2Cbye The querystring param "q" always has a value of "hi,bye". So why is the comma encoded? I want to do something like this https://stackoverflow.com/a/752109/173957 . I have this form: <form method="GET" action="/Search"> <input type="hidden" name="q" value="hi,bye"/> <input type="submit" value="ok"/> </form> How can I prevent this value from being encoded? The URI spec, RFC 3986 , specifies that URI path components not contain unencoded reserved characters and comma is one

UrlEncode和UrlDecode

谁都会走 提交于 2019-12-03 03:53:32
解决了一个疑惑,在此记录。 什么时候用UrlEncode和UrlDecode,也就是URL编码? 答:一般情况的GET和POST会自动编码解码,不需要显示地写代码。 遇到这样一种场景,需要写一个API跟别人对接,协议都说了用POST表单的方式。然而对方用contentType=“application/octet-stream”二进制流,且对字符串进行了编码。这类情况最好显示地解码   HttpUtility.UrlDecode(HttpContext.Current.Request.Form["userName"], Encoding.UTF8); 这样写,即可以正确解析这种xx的人发的请求,也能正确解析正常请求。 来源: https://www.cnblogs.com/chixiner/p/11775647.html

Why I can't use urlencode to encode json format data?

邮差的信 提交于 2019-12-03 02:53:23
I have a problem about urlencode in python 2.7: >>> import urllib >>> import json >>> urllib.urlencode(json.dumps({'title':"hello world!",'anonymous':False,'needautocategory':True})) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/urllib.py", line 1280, in urlencode raise TypeError TypeError: not a valid non-string sequence or mapping object Because urllib.urlencode "converts a mapping object or a sequence of two-element tuples to a “percent-encoded” string..." . Your string is neither of these. I think you need urllib.quote or urllib.quote

php的urlencode()URL编码函数浅析

寵の児 提交于 2019-12-03 02:50:43
URLEncode:是指针对网页url中的中文字符的一种编码转化方式,最常见的就是Baidu、Google等搜索引擎中输入中文查询时候,生成经过Encode过的网页URL。 URLEncode的方式一般有两种,一种是传统的基于GB2312的Encode(Baidu、Yisou等使用),另一种是基于UTF-8的Encode(Google、Yahoo等使用)。 本工具分别实现两种方式的Encode与Decode: 中文 -> GB2312的Encode -> %D6%D0%CE%C4 中文 -> UTF-8的Encode -> %E4%B8%AD%E6%96%87 Html中的URLEncode: 编码为GB2312的html文件中:http://s.jb51.net/中文.rar -> 浏览器自动转换为 -> http://s.jb51.net/%D6%D0%CE%C4.rar 注意:Firefox对GB2312的Encode的中文URL支持不好,因为它默认是UTF-8编码发送URL的,但是ftp://协议可以,我试过了,我认为这应该算是Firefox一个bug。 编码为UTF-8的html文件中:http://s.jb51.net/中文.rar -> 浏览器自动转换为 -> http://s.jb51.net/%E4%B8%AD%E6%96%87.rar

URLENCODE与RAWURLENCODE

℡╲_俬逩灬. 提交于 2019-12-03 02:50:20
我一直不能理解,为什么urlencode与标准的RFC文档有出入,所以对这个函数的用法一直心存疑虑。最近终于抽时间去检查了下stackoverflow上面对这个问题的解释,大概弄清楚了。 首先,对比一下两个函数的不同: 1)不予转义的字符:urlencode(_-.)共三个,rawurlencode( -_.~ )共四个,可见多了一个波浪线,前者会把波浪线转换为%7E。 2)特殊转义的字符:urlencode会把空格转换为+,rawurlencode则不会。 urlencode其实是post表单是用的编码方法,也是 application/x-www-form-urlencoded 的编码方法。对于URL的编码,更好的方法是符合RFC3986标准的rawurlencode,这也是js中的URIENCODE方法采用的标准。 来源: oschina 链接: https://my.oschina.net/u/127301/blog/98517

php URLEncode() / php URLEncode函数 php urldecode...

自作多情 提交于 2019-12-03 02:50:02
理解URLEncode: URLEncode:是指针对网页url中的中文字符的一种编码转化方式,最常见的就是Baidu、Google等搜索引擎中输入中文查询时候,生成经过 Encode过的网页URL。URLEncode的方式一般有两种一种是传统的基于GB2312的Encode(Baidu、Yisou等使用),一种是 基于UTF-8的Encode(Google,Yahoo等使用)。本工具分别实现两种方式的Encode与Decode。 中文 -> GB2312的Encode -> %D6%D0%CE%C4 中文 -> UTF-8的Encode -> %E4%B8%AD%E6%96%87 Html中的URLEncode: 编码为GB2312的html文件中, http://ud03.kinoko.name/中文.rar -> 浏览器自动转换为 -> http://ud03.kinoko.name/%D6%D0%CE%C4.rar 注意:Firefox对GB2312的Encode的中文URL支持不好,因为它默认是UTF-8编码发送URL的,但是ftp://协议可以,我试过了.我认为这应该算是Firefox一个bug. 编码为UTF-8的html文件中, http://ud03.kinoko.name/中文.rar -> 浏览器自动转换为 -> http://ud03.kinoko.name

PHP--------解决网址URL编码问题

浪子不回头ぞ 提交于 2019-12-03 02:49:48
在PHP中有urlencode()、urldecode()、rawurlencode()、rawurldecode()这些函数来解决网页URL编码解码问题。 理解urlencode: urlencode: 是指针对网页url中的中文字符的一种编码转化方式,最常见的就是Baidu、Google等搜索引擎中输入中文查询时候,生成经过 Encode过的网页URL。 urlencode的方式一般有两种一种是传统的基于GB2312的Encode(Baidu、Yisou等使用),一种是 基于utf-8的Encode(Google,Yahoo等使用)。本文分别分析两种方式的Encode与Decode。 中文 -> GB2312的Encode -> %D6%D0%CE%C4 中文 -> utf-8的Encode -> %E4%B8%AD%E6%96%87 Html中的urlencode: 编码为GB2312的html文件中: http://www.php.com/中文.rar -> 浏览器自动转换为 -> http://www.php.com/%D6%D0%CE%C4.rar 注意:Firefox对GB2312的Encode的中文URL支持不好,因为它默认是utf-8编码发送URL的,但是ftp://协议可以,应该算是Firefox一个bug。 编码为utf-8的html文件中: http:/

How to decode a (doubly) 'url-encoded' string in python

血红的双手。 提交于 2019-12-03 01:29:07
Tried decoding a url-encoded string in the following way some_string = 'FireShot3%2B%25282%2529.png' import urllib res = urllib.unquote(some_string).decode() res u'FireShot3+%282%29.png' Original string is FireShot3 (2).png . Any help would be appreciated. Answer: urllib.unquote_plus(urllib.unquote_plus(some_string)) due to double encoding. Your input is encoded double . Using Python 3: urllib.parse.unquote(urllib.parse.unquote(some_string)) Output: 'FireShot3+(2).png' now you have the + left. Edit: Using Python 2.7 it of course is: urllib.unquote(urllib.unquote('FireShot3%2B%25282%2529.png'))

Instagram API error 500 UTF-8 hashtags with enforced signature

安稳与你 提交于 2019-12-03 00:47:03
I am receiving 500 error from a simple instagram GET request. My code works when the hashtag contains normal ascii characters, or when my app has the checkbox "Enforce signed requests" unchecked. But I cannot get anything to work when I try with a utf8 hashtag and signed requests enforced. I saw that signed requests will be mandatory soon, so I need it to work. I want to get all images for a tag like #über. public static String signRequest(String key, String data) throws Exception { Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF

urllib和urllib2区别

匿名 (未验证) 提交于 2019-12-03 00:26:01
urllib和urllib2区别  urllib和urllib2区别:    Python的urllib和urllib2模块都做与请求URL相关的操作,但他们提供不同的功能。他们两个最显着的差异如下:   总结1:urllib2可以接受一个Request对象,并以此可以来设置一个URL的headers,但是urllib只接收一个URL。这意味着,你不能伪装你的用户代理字符串等。   总结2:urllib模块可以提供进行urlencode的方法,该方法用于GET查询字符串的生成,urllib2的不具有这样的功能。这就是urllib与urllib2经常在一起使用的原因。       A.urllib2概述   urllib2模块定义的函数和类用来获取URL(主要是HTTP的),他提供一些复杂的接口用于处理: 基本认证,重定向,Cookies等。   urllib2支持许多的“URL schemes”(由URL中的“:”之前的字符串确定 - 例如“FTP”的URL方案如“ftp://python.org/”),且他还支持其相关的网络协议(如FTP,HTTP)。我们则重点关注HTTP。   在简单的情况下,我们会使用urllib2模块的最常用的方法urlopen。但只要打开HTTP URL时遇到错误或异常的情况下,就需要一些HTTP传输协议的知识。我们没有必要掌握 HTTP RFC2616