0

I have started using VirusTotal & trying to generate URL report. The URL that I am using to test the code is "https://xyqhsservice-logg.in/" which has a 503 status code but somehow the API endpoint is not working. I checked the documentation https://developers.virustotal.com/reference/url-info#:~:text=Get%20a%20URL%20analysis%20report%20get%20https%3A%2F%2Fwww.virustotal.com%2Fapi%2Fv3%2Furls%2F%7Bid%7D%20See,start%20a%20request%20and%20see%20the%20response%20here%21 & used the same endpoint get request I am new to VirusTotal API would be great if someone can help.Below is my code:

import requests
# Your VirusTotal API key
api_key = "key"

# URL to query
url_to_query = "https://xyqhsservice-logg.in/"

# VirusTotal API endpoint for URL reports
url = f"https://www.virustotal.com/api/v3/urls/{url_to_query}"

# Set headers with your API key
 headers = {
 "x-apikey": api_key
  }

try:
   # Get URL report
   response = requests.get(url, headers=headers)
   if response.status_code == 503:
       url_info = response.json()
       print("URL Analysis Report:")
       print(f"URL: {url_info['data']['id']}")
       print(f"Scan Date: {url_info['data']['attributes']['last_analysis_date']}")
       print(f"Positives: {url_info['data']['attributes']['last_analysis_stats']['malicious']}")
   print(f"Total Scans: {url_info['data']['attributes']['last_analysis_stats']['total']}")
   print(f"Scan Results:")
   for engine, result in url_info['data']['attributes']['last_analysis_results'].items():
       print(f"  {engine}: {'malicious' if result['category'] == 'malicious' else 'clean'}")
   else:
      print(f"Error querying URL {url_to_query}: {response.text}")

   except Exception as e:
     print(f"Error querying URL {url_to_query}: {e}")

The error I am getting is:

Error querying URL https://xyqhsservice-logg.in/: {"error": 
{"code":"NotFoundError","message":"Resource not found."}}
user6016731
  • 382
  • 5
  • 18

0 Answers0