Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

extract the domain name from the urls in another list

extract the domain name from the urls in another list. Also you need to extract the ending string which the url ends with.
For example, https://www.example.com/market.php — In this example, domain name is www.example.com and the ending string is php

Extract the domains and the ending string
# List of urls
url_list = ['https://blog.hubspot.com/marketing/parts-url',
            'https://www.almabetter.com/enrollments',
            'https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rename.html',
            'https://www.programiz.com/python-programming/list']

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use urlparse(url) from urllib! (from urllib.parse import urlparse):

parsed_url = urlparse(url)

domain = parsed_url.netloc
ending = parsed_url.path.split('.')[-1]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading