Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django request.GET.GET()截断url字符串_Python_Django_Google Chrome Extension - Fatal编程技术网

Python Django request.GET.GET()截断url字符串

Python Django request.GET.GET()截断url字符串,python,django,google-chrome-extension,Python,Django,Google Chrome Extension,我正在使用chrome.runtime.sendMessage从chrome扩展向本地运行的django应用程序发送一条消息。我能够在url中捕获消息,但不知何故,整个GET参数没有被捕获。比如说, "GET /sensitiveApi/?text=%20%20%20%20The%20Idiots%20-%20Rainbow%20Six%20Siege%20Funny%20Moments%20&%20Epic%20Stuff%20%20We%27re%20back%20with%20s

我正在使用
chrome.runtime.sendMessage
从chrome扩展向本地运行的django应用程序发送一条消息。我能够在url中捕获消息,但不知何故,整个GET参数没有被捕获。比如说,

 "GET /sensitiveApi/?text=%20%20%20%20The%20Idiots%20-%20Rainbow%20Six%20Siege%20Funny%20Moments%20&%20Epic%20Stuff%20%20We%27re%20back%20with%20some%20Rainbow%20Six%20Siege%20funny%20moments!%20All%20clips%20were%20streamed%20live%20on%20my%20Twitch:%20https://www.twitch.tv/teosgameMore%20Siege%20funny%20moments:%20https://www.youtube.com/playlist?list...Discord:%20https://discord.gg/teoTwitter:%20https://twitter.com/LAGxPeanutPwnerInstagram:%20https://www.instagram.com/photeographPeople%20in%20video:Alex:%20https://twitter.com/AlexandraRose_GKatie:%20https://www.twitch.tv/katielouise_jKatja:%20https://www.twitch.tv/katjawastakenPaddy:%20https://twitter.com/Patward96Smii7y:%20https://www.youtube.com/user/SMii7YSnedger:%20https://www.twitch.tv/snedgerStefan:%20https://twitter.com/lagxsourTortilla:%20https://twitter.com/Tortilla_NZColderMilk:%20https://www.youtube.com/user/ColderMilkColderMilk%20Twitch:%20https://www.twitch.tv/colder_milkColderMilk:%20Twitter:%20https://twitter.com/colder_milkMusic%20used:Outro:%20Come%20Back%20from%20San%20Francisco%20(Instrumental)%20by%20Rameses%20B%20https://www.youtube.com/watch?v=fBWac...%20Go%20check%20out%20his%20music!%20:)%20https://www.youtube.com/RamesesB2 HTTP/1.1" 200 2
这是我想要捕获的一个响应,我正在做一个
request.GET.GET('text','')
,但它返回的只是这个

 The Idiots - Rainbow Six Siege Funny Moments
如何捕获整个GET参数

这就是我如何使用chrome.runtime.sendMessage

chrome.runtime.sendMessage({
        method: 'GET',
        action: 'xhttp',
        url: "http://127.0.0.1:8000/sensitiveApi/?text=",
        data : text
    });
需要进行百分比编码的未转义符号和(&):

>>> import urllib
>>> print(urllib.quote('&'.encode('utf-8')))
%26
url(
http://www.example.com?fields=name&age
&
)看起来像下面提到的值:

url = http://www.example.com?fields=name%26age

URL中有一个未加引号的
&
。在您提供的示例中有一个未加引号的符号(
&
)。Django将其解释为新查询参数的开始。在将消息发送到Django之前,您需要避开此问题。我如何更正它?不带引号的
&
可以到任何地方,对吗<代码>文本这里表示
YouTube
视频标题和描述我在发送到django服务器之前在文本中添加了encodeURIComponent,但这看起来也不错。谢谢