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

时间:2017-06-10 09:11:36

标签: python django google-chrome-extension

我正在使用 "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 从Chrome扩展程序向本地运行的django应用程序发送消息。我能够在URL中捕获消息,但不知何故没有捕获整个GET参数。例如,

request.GET.get('text', '')

这是我要捕获的一个响应,我正在做 The Idiots - Rainbow Six Siege Funny Moments ,但它返回的只是这个,

chrome.runtime.sendMessage

如何捕获整个GET参数?

这就是我使用chrome.runtime.sendMessage({ method: 'GET', action: 'xhttp', url: "http://127.0.0.1:8000/sensitiveApi/?text=", data : text });

的方式
<Button Grid.Column="0" Grid.Row="5" 
        HorizontalAlignment="Center" 
        Margin="88,8,214,0"  
        Grid.RowSpan="2" Height="26" 
        VerticalAlignment="Top" Width="22"
        IsEnabled="{Binding Path=SearchFound}" 
        x:Name="cmdPlanList" 
        Click="cmdPlanList_Click">
    <ContentControl>
        <Popup IsOpen = "{Binding PlanPopup}"
               PlacementTarget = "{Binding ElementName = cmdPlanList}"
               AllowsTransparency = "True" 
               PopupAnimation = "Slide" 
               x:Name="Popup4Plan">
            <Canvas Width = "125" 
                    Height = "100" 
                    Background = "Red" >
                <Canvas.RenderTransform>
                    <RotateTransform x:Name = "theTransform" />
                </Canvas.RenderTransform>
                <TextBlock TextWrapping = "Wrap" 
                           Foreground = "Blue"  
                           Text = "Hi, this is Popup" />
            </Canvas>
        </Popup>
    </ContentControl>
</Button>

1 个答案:

答案 0 :(得分:1)

未转义的&符号(&amp;),需要进行百分比编码:

>>> import urllib
>>> print(urllib.quote('&'.encode('utf-8')))
%26
带有http://www.example.com?fields=name&age

url(&)看起来像下面提到的值:

url = http://www.example.com?fields=name%26age
相关问题