def check_api(key): try: urllib.request.urlopen('https://www.duckduckgo.com') # opens url to check internet connection scanner = Virustotal(key) scanner.url_scan(['www.vulnweb.com']) report = scanner.url_report(['www.vulnweb.com']) if report['status_code'] == 403: # checks if status code is 403 return True else: return False except urllib.error.URLError: input('Connect to internet...') exit()
def check_url(key): url = input('\nEnter URL: ') # Get url from the user try: urllib.request.urlopen('http://' + url) # Checks the given url is valid msg() # prints scanning message scanner = Virustotal(key) # passing api key to Virustotal class scanner.url_scan([url]) # passing url to url_scan function report = scanner.url_report([url]) # returns report of the url try: print('\n\nREPORT:\nStatus_code:', report['status_code']) # Prints all the reports print('Scan date:', report['json_resp']['scan_date']) print('URL:', report['json_resp']['url']) print('Verbose msg:', report['json_resp']['verbose_msg']) print('Total Scanned:', report['json_resp']['total']) print('Positives:', report['json_resp']['positives']) except KeyError: print('\n""Maximum four scans per minute""') # prints if you reach maximum attempts except: print('Invalid URL')