How to Check a URL for Phishing Threats in Python

Cloudmersive
2 min readMar 8, 2021

--

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 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.PhishingCheckRequest() # PhishingCheckRequest | Input URL request
try:
# Check a URL for Phishing threats
api_response = api_instance.domain_phishing_check(request)
pprint(api_response)
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 Cloudmersive website to register for a free account and gain access to 800 monthly calls across our library of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet