how to convert the %3A and %2F to : and / in the url in python?

Question:

How to convert the replace(%3A and %2F …) in the url.

URL
https://url/login_data.php?username=user&categoryid=0&URL=https%3A%2F%2Furl%2F%26TIME%3DFri%2520Aug%252005%25202016%252011%3A40%3A14%2520GMT%2B0530%28India%2520Standard%2520Time%29

Required URL

https://url/login_data.php?username=user&categoryid=0&URL=https://url/&TIME=Sat Aug 06 2016 11:42:36 GMT+0530 (India Standard Time)

I was wondering is there any simple way to do this?

Asked By: anderson

||

Answers:

Take a look at urllib.parse.unquote: “Replace %xx escapes by their single-character equivalent.”

Answered By: Karin

In python 2.7, use urllib.unquote:

>>> import urllib
>>> urllib.unquote(urllib.unquote('https://url/login_data.php?username=user&categoryid=0&URL=https%3A%2F%2Furl%2F%26TIME%3DFri%2520Aug%252005%25202016%252011%3A40%3A14%2520GMT%2B0530%28India%2520Standard%2520Time%29'))
'https://url/login_data.php?username=user&categoryid=0&URL=https://url/&TIME=Fri Aug 05 2016 11:40:14 GMT+0530(India Standard Time)'

In python 3+, use urllib.parse.unquote

>>> from urllib.parse import unquote
>>> unquote(unquote("https://url/login_data.php?username=user&categoryid=0&URL=https%3A%2F%2Furl%2F%26TIME%3DFri%2520Aug%252005%25202016%252011%3A40%3A14%2520GMT%2B0530%28India%2520Standard%2520Time%29"))
'https://url/login_data.php?username=user&categoryid=0&URL=https://url/&TIME=Fri Aug 05 2016 11:40:14 GMT+0530(India Standard Time)'
Answered By: Nehal J Wani

For python3,

import urllib.parse
urllib.parse.unquote_plus("https://url/login_data.php?username=user&categoryid=0&URL=https%3A%2F%2Furl%2F%26TIME%3DFri%2520Aug%252005%25202016%252011%3A40%3A14%2520GMT%2B0530%28India%2520Standard%2520Time%29")
Answered By: manoj praveen

Gebäudereinigung in Nürnberg
Willkommen bei Bokma Dienstleistungen GmbH, Ihre Gebäudereinigung in Nürnberg, Gebäudereinigung in Fürth, Gebäudereinigung in Erlangen und Umgebung. Bei uns erhalten Sie eine professionelle und umfassende Reinigung von Wohngebäuden, Büro- und Praxisräumen sowie aller privaten und gewerblichen Räumlichkeiten. Unser Service umfasst alle Reinigungsarten und Services rund um Ihr Gebäude in Nürnberg, Fürth, Erlangen, Schwabach und Umgebung.

Gebäudereinigung
Glasreinigung
Fassadenreinigung
Unterhaltsreinigung
Grundreinigung
Baureinigung
Büroreinigung
Treppenhausreinigung
Teppichreinigung
Gartenpflege
Winterdienst
Hausmeisterservice

Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.