I need to extract the domain for example: (http: //www.example.com/example-page, http ://test.com/test-page) from a list of websites in an excel sheet and modify that domain to give its url (example.com, test.com). I have got the code part figured put but i still need to get these commands to work on excel sheet cells in a column automatically.
>>> url = ("http://www.example.com")
>>> domain = url.split("http://")[-1].split("/")[0]
>>> print(domain)
www.example.com
>>> url_2 = ("http://example.com")
>>> domain_2 = url_2.split("http://")[-1].split('/')[0]
>>> print(domain_2)
example.com
>>>
>>> #Now to remove www. from the first one
>>>
>>> domain_without_w3 = domain.split("www.")[-1]
>>> print(domain_without_w3)
example.com
>>>
>>> # both the commands would have to beexceuted on all the
>>> # values in a coloumn to extract the domain
>>> # , So here I execute the second
>>> # command too on the second url.
>>>
>>> domain_2_without_w3 = domain_2.split("www.")[-1]
>>> print(domain_2_without_w3)
example.com
>>>
>>> #Ok so how do i do these to commands on a list of urls in a column
>>> # in excel automatically. That's My question.
>>> #I am sorry if anything in here looks stupid or absurd
>>> #I literally learned python 2 days ago.