urlDecode()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gert

    urlDecode()

    Anybody can tell me what i need to import to make urlDecode() work in
    python2.5 please.

    import urllib
    urllib.urlDecod e(post) #doesn't exist
    urllib.urldecod e(post) #doesn't exist
    urldecode(post) #doesn't exist
    urlDecode(post) #doesn't exist

  • gert

    #2
    Re: urlDecode()

    import re

    def htc(m):
    return chr(int(m.group (1),16))

    def urldecode(url):
    rex=re.compile( '%([0-9a-hA-H][0-9a-hA-H])',re.M)
    return rex.sub(htc,url )

    if __name__ == '__main__':
    print urldecode('adas asdasd%20asdasd asdas')

    Ok thats it enough googeling around i make one my self :)

    Comment

    • Gabriel Genellina

      #3
      Re: urlDecode()

      En Wed, 28 Feb 2007 22:45:40 -0300, gert <gert.cuykens@g mail.comescribi ó:
      import re
      >
      def htc(m):
      return chr(int(m.group (1),16))
      >
      def urldecode(url):
      rex=re.compile( '%([0-9a-hA-H][0-9a-hA-H])',re.M)
      return rex.sub(htc,url )
      >
      if __name__ == '__main__':
      print urldecode('adas asdasd%20asdasd asdas')
      >
      Ok thats it enough googeling around i make one my self :)
      You reinvented urllib.unquote

      --
      Gabriel Genellina

      Comment

      • gert

        #4
        Re: urlDecode()

        On Mar 1, 1:40 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a rwrote:
        En Wed, 28 Feb 2007 22:45:40 -0300, gert <gert.cuyk...@g mail.comescribi ó:
        >
        import re
        >
        def htc(m):
        return chr(int(m.group (1),16))
        >
        def urldecode(url):
        rex=re.compile( '%([0-9a-hA-H][0-9a-hA-H])',re.M)
        return rex.sub(htc,url )
        >
        if __name__ == '__main__':
        print urldecode('adas asdasd%20asdasd asdas')
        >
        Ok thats it enough googeling around i make one my self :)
        >
        You reinvented urllib.unquote
        >
        lol ok i am not going to argue about why they call it unquote


        Comment

        Working...