首页 > 解决方案 > 如何解决“[Winerror]:10054 现有连接被远程主机强行关闭”?

问题描述

我正在尝试使用 VirusTotal API 获取 json 响应。为了获取结果作为响应,我创建了一个 python 脚本,如下所示: 然后错误显示如下: [Winerror]:10054 现有连接被远程主机强行关闭

import requests

url = "https://www.virustotal.com/vtapi/v2/file/scan"

api_key = "MyApiKey"

params = {"apikey": api_key}

files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb")} 
try:
    response = requests.post(url, files=files, params=params)
    print(response.json())

except Exception as e:
    print(e)

在此处输入图像描述

标签: pythonmalwaremalware-detection

解决方案


要提供更多信息,请尝试以下操作:

import requests

url = "https://www.virustotal.com/vtapi/v2/file/scan"

api_key = "MyApiKey"

params = {"apikey": api_key}

files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb"))} 
try:
    response = requests.post(url, files=files, params=params)
    print(response.json())

except Exception as e:
    print(e)

并发布您从更新代码中收到的错误响应。


推荐阅读