I am having problem with removing certain URLs from a list in Python. I want to know the easiest and quickest way.
I got a list of URLs returned from google search API. I want to remove all the websites which have the domain "trip advisor", "facebook", "instagram", "twitter" and "ebag".
Here is what I have tried so far:
page_urls = ['https://the1955club.com/', 'https://www.tripadvisor.com/Restaurant_Review-g1842228-d10140470-Reviews-The_1955_Club-Walton_On_Thames_Surrey_England.html']
# print('page_urls', page_urls)
all_urls = []
for address in page_urls:
url = urlparse(address)
new_url = url.netloc
all_urls.append(new_url)
all_urls.remove('www.tripadvisor.com')
all_urls.remove('tripadvisor.com')
I am getting this error:
ValueError: list.remove(x): x not in list