i want compare 2 url's a="https://example.com/rghj.mp3" , b="http://example.com/rghj.mp3" . want make condition ignores s in https , compares these 2 url's , evaluates true.what best way ? trying a.split("//:")[1]==b.split("//:")[1].does code break url format ?
quick , dirty:
a.replace("https://","http://") == b.replace("https://","http://")
depending on use case, may want take more robust approach.
from urllib.parse import urlparse a_url = urlparse(a) b_url = urlparse(b) match = a_url.netloc == b_url.netloc
Comments
Post a Comment