Validate a URL in Python
Online security is a top priority in the modern business world. Thus, knowing whether website links are safe will help you prevent any threats to your operations. Furthermore, it is important to know if you have collected the correct information about a website, particularly if you are using it for potential leads. The following API will validate a URL in full. This means that it will check whether the URL is syntactically valid, whether the URL exists, and whether the endpoint is running and passes virus scan checks.
Run this command to install the SDK:
pip install cloudmersive-validate-api-client
Then, you can call the function:
from __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_validate_api_client.DomainApi(cloudmersive_validate_api_client.ApiClient(configuration))
request = cloudmersive_validate_api_client.ValidateUrlRequestFull() # ValidateUrlRequestFull | Input URL requesttry:
# Validate a URL fully
api_response = api_instance.domain_url_full(request)
pprint(api_response)
except ApiException as e:
print("Exception when calling DomainApi->domain_url_full: %s\n" % e)
This will return responses for whether the URL, syntax, domain, and endpoint are valid, as well as a string containing the standardized URL. You can retrieve the API Key from the Cloudmersive website at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.