Issue
I have two types of addresses in DataBase:
url_1 = "http://country.city.street/"
url_2 = "http://country.city.street:8180/"
I need to get a uniform address format (url_pattern = "country.city.street"
) to use in a DNS server. I removed the http://
part from the beginning but can't get a good result with the end of the address. Does anyone have an idea what I could use to get a url_pattern
standard?
url_1 = "http://country.city.street/"
url_2 = "http://country.city.street:8180/"
url_1 = url_1[7:]
url_2 = url_2[7:]
Solution
There is standard module for URL parsing
from urllib.parse import urlparse
print(urlparse("http://country.city.street:8180/").hostname)
Answered By - farincz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.