How to Check a URL for Phishing Threats in Python

If you have an email address, chances are you’ve been the target of a phishing attack at least once or twice. Phishing attacks are one of the most common forms of cyber threats; they attempt to obtain sensitive information (i.e. social security number, date of birth, credit card information, etc.) by posing as a reliable contact or website. Many of these attackers send malicious URL links to lure you into clicking the phony site and supplying your information. The following API can assist you in protecting yourself and your clients from these threats by automatically checking if an input URL is a risk factor.

To kick things off, we are going to run this command to install the API client:

pip install cloudmersive-validate-api-client

Now we’ll move on to calling the function:

from __future__ import print_function
import time
import cloudmersive_validate_api_client
from 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.PhishingCheckRequest() # PhishingCheckRequest | Input URL request
# Check a URL for Phishing threats
api_response = api_instance.domain_phishing_check(request)
except ApiException as e:
print("Exception when calling DomainApi->domain_phishing_check: %s\n" % e)

Voila! The returned response will indicate if the URL is clean, as well as the threat type (if a threat was detected). To retrieve your API key, head over to the to register for a free account and gain access to 800 monthly calls across our library of APIs.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.