Skip to content

Latest commit

 

History

History
50 lines (29 loc) · 1.93 KB

Python_Convert_URL_to_string.md

File metadata and controls

50 lines (29 loc) · 1.93 KB



Template request | Bug report | Generate Data Product

Tags: #python #urllib #string #url #convert #library

Author: Florent Ravenel

Description: This notebook will show how to convert a URL to a string using urllib.

References:

Input

Import libraries

import urllib.parse

Setup Variables

  • url: URL to be converted to string
url = "https://www.pythonforbeginners.com/urllib/how-to-use-urllib-in-python"

Model

Convert URL to string

The unquote() function in urllib.parse converts percent-encoded characters in the URL back to their original form. In this example, the URL is already in string form, so unquote() simply returns the same string.
If the URL had any percent-encoded characters, they would be decoded by unquote().

string = urllib.parse.unquote(url)

Output

Display result

print(string)