URL Scanner Using VirusTotal API And Python

PHOTO EMBED

Sat Apr 19 2025 09:47:10 GMT+0000 (Coordinated Universal Time)

Saved by @freepythoncode ##python #coding #python #url #securty

from dotenv import load_dotenv
from os import getenv
import vt

load_dotenv()

"""
requirements :
pip install python-dotenv==1.1.0
pip install vt_py==0.20.0

1 - Create account in https://www.virustotal.com/
2 - Copy your API Key and but it into .env file or put it into your script

"""
apikey = getenv('api_key')

url = input('URL:')

stats_meaning = {
    'malicious': 'No engine explicitly marked this URL as malicious (i.e., known for phishing, malware, scams, etc.). ✅',
    'suspicious': 'No engine thought the URL looked suspicious or sketchy based on patterns or heuristics. ✅',
    'harmless': 'engines scanned the URL and found it to be safe. ✅',
    'undetected': 'engines scanned it but didn’t detect anything, which often means they didn’t have an opinion one way or the other — like saying “no result.” 🟡',
    'timeout': 'No engines timed out while analyzing the URL. ✅',
}

with vt.Client(apikey=apikey) as client:
    analysis = client.scan_url(url=url, wait_for_completion=True)
    stats = analysis.stats
    for k in stats:
        print(f"{k} : {str(stats[k])} {stats_meaning[k].capitalize()}")


content_copyCOPY