0

Is it possible to change an URL which contains percent signs like

 http%3A%2F%2Funiversities.ac%2Fshow_article.php%3Fid%3D61&amp

to normal URL readable by human like

http://universities.ac/show_article.php?id=61

using Selenium?

albert
  • 8,027
  • 10
  • 48
  • 84
Milano
  • 18,048
  • 37
  • 153
  • 353
  • possible duplicate of [Decode escaped characters in URL](http://stackoverflow.com/questions/8136788/decode-escaped-characters-in-url) – JeffC Aug 30 '15 at 23:11

2 Answers2

3

This doesn't really have anything to do with Selenium. You can use the urlparse module in the standard library.

from urlparse import unquote      # python2
from urllib.parse import unquote  # python3
unquote('http%3A%2F%2Funiversities.ac%2Fshow_article.php%3Fid%3D61&amp')
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • The ampersand `&` (HTML-entity: `&amp`) at the and of the URL does not seem to be unquoted. As a quick workaround you could pass the unquoted URL string to [`html.unencode()`](https://docs.python.org/3/library/html.html#html.unescape) in oder to convert HTML-entities – albert Aug 30 '15 at 20:58
1

You can use urllib unquote as follows

url='http%3A%2F%2Funiversities.ac%2Fshow_article.php%3Fid%3D61&amp'
url=urllib.unquote(url).decode('utf8') 
Arturs Vancans
  • 4,531
  • 14
  • 47
  • 76