In This Tutorial We will Develop a Python script that takes a company’s name as input and retrieves its official website URL using a search engine. The script should return the most relevant result that matches the official domain.
To Get Official Website URL from Company Name in Python
You can use the googlesearch-python package for better and easy way to develop this code
from googlesearch import search def get_official_website(write_company_name): query = f"{write_company_name} official site" for result in search(query, num=5, stop=5, pause=2): if write_company_name.lower() in result.lower(): return result return "Website not found" company = "code speedy" print(get_official_website(company))
This searches Google and returns the first result that looks like an official website
The script should return the official website URL of the given company.
Results: input: code speedy output: https://code speedy.com
If the website is not found, it should return:
output: Website not found
1. Use a search engine (like Google) to look for the company’s official site.
2. Filter results to find the most relevant one.
3. Return the official website URL or a message if not found.
By following this steps we will get official website url from company name in python